I created a ticket, but appears that one was already created 2 days
ago.

On Nov 24, 11:06 am, PhiKapJames <phikapja...@gmail.com> wrote:
> Found an issue with using multiple databases.  I'm using the lastest
> 1.4 tag updated up to 20 minutes ago.  To test the issue, I created a
> test project and documented the steps I used to have the issue.
>
> The issue seems to be that no matter what connection is specified,
> once the model is used, it will always try to use the last connection
> in the list.  Here's what I did.
>
> I created two databases quickly:
> CREATE DATABASE `test1`;
> CREATE TABLE IF NOT EXISTS `Rebel` (
>   `RebelID` int(11) NOT NULL auto_increment,
>   `RebelName` varchar(32) NOT NULL,
>   `BallOrChain` tinyint(4) NOT NULL,
>   PRIMARY KEY  (`RebelID`)
> ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
>
> CREATE DATABASE `test2`;
> CREATE TABLE IF NOT EXISTS `Song` (
>   `Sacred` int(11) NOT NULL,
>   `Heart` varchar(32) NOT NULL,
>   UNIQUE KEY `Sacred` (`Sacred`)
> ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
>
> I then configured the databases in sf:
> ./symfony configure:database --name=test1 --class=sfDoctrineDatabase
> "mysql:host=localhost;dbname=test1" test1 test1
> ./symfony configure:database --name=test2 --class=sfDoctrineDatabase
> "mysql:host=localhost;dbname=test2" test2 test2
>
> $ cat config/databases.yml
> all:
>   test1:
>     class: sfDoctrineDatabase
>     param:
>       dsn: 'mysql:host=localhost;dbname=test1'
>       username: test1
>       password: test1
>   test2:
>     class: sfDoctrineDatabase
>     param:
>       dsn: 'mysql:host=localhost;dbname=test2'
>       username: test2
>       password: test2
>
> Then I ran all the normal things:
> ./symfony doctrine:build-schema
> ./symfony doctrine:build-model
> ./symfony doctrine:build-form
> ./symfony doctrine:build-filters
>
> ./symfony doctrine:generate-module --with-show --non-verbose-templates
> frontend rebel rebel
> ./symfony doctrine:generate-module --with-show --non-verbose-templates
> frontend song song
>
> Verified that the model created correctly with the connection
> specified in base:
> $ head lib/model/doctrine/base/BaseRebel.class.php
> <?php
> // Connection Component Binding
> Doctrine_Manager::getInstance()->bindComponent('Rebel', 'test1');
>
> Now if I go tohttp://test.localhost/frontend_dev.php/rebel, I get an
> error:
> SQLSTATE[42S02]: Base table or view not found: 1146 Table
> 'test2.Rebel' doesn't exist. Failing Query: "SELECT r.rebelid AS
> r__rebelid, r.rebelname AS r__rebelname, r.ballorchain AS
> r__ballorchain FROM Rebel r"
>
> From this I see that it's still trying to use the test2 connection
> even though everything is telling it to go to db test1.
>
> If I go tohttp://test.localhost/frontend_dev.php/songit uses the
> correct connection (test2).
>
> Did I do something wrong here?  I really could use some help on this
> to get it working because it's doing the same thing in my real project
> I'm developing and in the test project I created real quick.

--

You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-us...@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