/**
  * Initialize a sfDoctrineDatabase connection with the given parameters.
  *
  * <code>
  * $parameters = array(
  *    'name'       => 'doctrine',
  *    'dsn'        => 'sqlite:////path/to/sqlite/db');
  *
  * $p = new sfDoctrineDatabase($parameters);
  * </code>
  *
  * @param array $parameters  Array of parameters used to initialize the database connection
  * @return void
  */
 public function initialize($parameters = array())
 {
     parent::initialize($parameters);
     $dsn = $this->getParameter('dsn');
     $name = $this->getParameter('name');
     // Make sure we pass non-PEAR style DSNs as an array
     if (!strpos($dsn, '://')) {
         $dsn = array($dsn, $this->getParameter('username'), $this->getParameter('password'));
     }
     // Make the Doctrine connection for $dsn and $name
     $this->_doctrineConnection = Doctrine_Manager::connection($dsn, $name);
     $attributes = $this->getParameter('attributes', array());
     foreach ($attributes as $name => $value) {
         $this->_doctrineConnection->setAttribute($name, $value);
     }
     $encoding = $this->getParameter('encoding', 'UTF8');
     $eventListener = new sfDoctrineConnectionListener($this->_doctrineConnection, $encoding);
     $this->_doctrineConnection->addListener($eventListener);
     // Load Query Logger Listener
     if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
         $this->_doctrineConnection->addListener(new sfDoctrineLogger());
     }
     // Invoke the configuration methods for the connection if they exist
     $configuration = sfProjectConfiguration::getActive();
     $method = sprintf('configureDoctrineConnection%s', ucwords($this->_doctrineConnection->getName()));
     if (method_exists($configuration, 'configureDoctrineConnection') && !method_exists($configuration, $method)) {
         $configuration->configureDoctrineConnection($this->_doctrineConnection);
     }
     if (method_exists($configuration, $method)) {
         $configuration->{$method}($this->_doctrineConnection);
     }
 }
 /**
  * Initialize a sfDoctrineDatabase connection with the given parameters.
  *
  * <code>
  * $parameters = array(
  *    'name'       => 'doctrine',
  *    'dsn'        => 'sqlite:////path/to/sqlite/db');
  *
  * $p = new sfDoctrineDatabase($parameters);
  * </code>
  *
  * @param array $parameters  Array of parameters used to initialize the database connection
  * @return void
  */
 public function initialize($parameters = array())
 {
     parent::initialize($parameters);
     if (null !== $this->_doctrineConnection) {
         return;
     }
     $dsn = $this->getParameter('dsn');
     $name = $this->getParameter('name');
     // Make sure we pass non-PEAR style DSNs as an array
     if (!strpos($dsn, '://')) {
         $dsn = array($dsn, $this->getParameter('username'), $this->getParameter('password'));
     }
     // Make the Doctrine connection for $dsn and $name
     $configuration = sfProjectConfiguration::getActive();
     $dispatcher = $configuration->getEventDispatcher();
     $manager = Doctrine_Manager::getInstance();
     $this->_doctrineConnection = $manager->openConnection($dsn, $name);
     $attributes = $this->getParameter('attributes', array());
     foreach ($attributes as $name => $value) {
         if (is_string($name)) {
             $stringName = $name;
             $name = constant('Doctrine_Core::ATTR_' . strtoupper($name));
         }
         if (is_string($value)) {
             $valueConstantName = 'Doctrine_Core::' . strtoupper($stringName) . '_' . strtoupper($value);
             $value = defined($valueConstantName) ? constant($valueConstantName) : $value;
         }
         $this->_doctrineConnection->setAttribute($name, $value);
     }
     $encoding = $this->getParameter('encoding', 'UTF8');
     $eventListener = new sfDoctrineConnectionListener($this->_doctrineConnection, $encoding);
     $this->_doctrineConnection->addListener($eventListener);
     // Load Query Profiler
     if ($this->getParameter('profiler', sfConfig::get('sf_debug'))) {
         $this->profiler = new sfDoctrineConnectionProfiler($dispatcher, array('logging' => $this->getParameter('logging', sfConfig::get('sf_logging_enabled'))));
         $this->_doctrineConnection->addListener($this->profiler, 'symfony_profiler');
     }
     // Invoke the configuration methods for the connection if they exist (deprecated in favor of the "doctrine.configure_connection" event)
     $method = sprintf('configureDoctrineConnection%s', ucwords($this->_doctrineConnection->getName()));
     if (method_exists($configuration, 'configureDoctrineConnection') && !method_exists($configuration, $method)) {
         $configuration->configureDoctrineConnection($this->_doctrineConnection);
     }
     if (method_exists($configuration, $method)) {
         $configuration->{$method}($this->_doctrineConnection);
     }
     $dispatcher->notify(new sfEvent($manager, 'doctrine.configure_connection', array('connection' => $this->_doctrineConnection, 'database' => $this)));
 }
 public function configureDoctrineConnectionDoctrine2(Doctrine_Connection $connection)
 {
     $connection->setAttribute(Doctrine_Core::ATTR_VALIDATE, false);
 }
 public function configureDoctrineConnectionDoctrine2(Doctrine_Connection $connection)
 {
     $connection->setAttribute('validate', false);
 }