I have a problem using multiple databases in doctrine.

I  start by making a myFilter:

class myFilter extends sfFilter
{
  public function execute ($filterChain)
  {
    // Code to execute before the action execution
      $env = $this->getContext()->getConfiguration()->getEnvironment
();
      $configuration = $this->getContext()->getInstance()-
>getConfiguration()->getApplicationConfiguration(sfConfig::get
('sf_app'),$env,0);
      //print_r(sfConfig::getAll());
      $myDatabaseManager = new myDatabaseManager($configuration);
      $myDatabaseManager->initialize($configuration);

    // Execute next filter in the chain
    $filterChain->execute();
    // Code to execute after the action execution, before the
rendering

  }
}

then i make a myDatabaseManager like this example:
http://groups.google.com/group/symfony-users/browse_thread/thread/b89bcc66e3b70a59


class myDatabaseManager extends sfDatabaseManager{

        public function initialize(sfApplicationConfiguration $config)
{

                $test = myTools::getDatabase() ;

                if(!isset($test)) $test = 'db' ;
                $parameters = array(
                    'dsn' => 'mysql:host=localhost;dbname='.$test,
                    'username' => 'root',
                    'password' => 'root',
                    'name'    => 'doctrine',
                    );
                //echo sfContext::getInstance()->getUser()-
>hasAttribute('new');
                $database = new sfDoctrineDatabase( $parameters);
                 /*$database->initialize(array(
                  'name' => 'doctrine',
                  'username' => 'root',
                  'password' => 'root',
                  'dsn' =>
'mysql:host=localhost;dbname=dgsic_teste'));*/

                $this->databases = $database;

                $this->databases->connect();

        }
}

On the filter.yml of the app I put:


rendering: ~
security:  ~

# insert your own filters here
database_new:
    class: myFilter

cache:     ~
common:    ~
execution: ~

But symfony always uses the connection from databases.yml. I override
sfDoctrineDatabase.class.php and notice that a connection prior to the
one i did is done to the database.yml  but don't know why.
Can you help me on this, dind't find any answers to the problem and I
google it.

thank you in advance.

Filipe Costa
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to