I'm afraid that this solution isn't possible in our case. We use replication (in MySQL) for one of the databases but not the other. If we use the prefix method, the records won't be replicated correctly. We need to do an actual database change in order for it to work.

It would be nice to be able to change database with something like $db->setParam("dbname", "somename") on the Zend_Db_Adapter. I tried changing the dbname directly with $db->_config["dbname"], but the config property is set as protected.

I have set up one adapter for each database for now, and it works fine. I'm not sure if it's the best way to do it, though. Will doing so result in two concurrent database connections?


Thanks for your help,

David Brännlund
Web & Database Development
COMSOL AB, Sweden

Mislav Marohnić wrote:
You don't even need to switch databases. Put a database prefix to the tables:

UPDATE other_db.mytable SET blah blah ...

It should work.

-M

On 10/9/06, * David Brännlund* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:

    Hi everyone,

    I have a class extending Zend_Db_Table with a bunch of methods doing all
    kinds of things. In one of the methods I need to update data in a
    different database. That database exists on the same server, so
    normally
    I would call mysql_select_db(dbname).

    How would I do this in ZF using Zend_Db?


    David Brännlund
    Web & Database Development
    COMSOL AB, Sweden



Reply via email to