开发者

CodeIgniter 2 + Doctrine 2 with multiple database connections

I was wondering if is possible to have CodeIgniter 2 with Doctrine 2 with multiple database connections.

I currently got CodeIgniter 2 and Doctrine 2 to work with 1 database, but is it possible开发者_如何学JAVA to do multiple database?

If so, how can this be accomplished?


I am unsure if you can do this where the two databases interact directly. (Cross-Database Joins/etc..)

However in your load-up for doctrine you probably have something along the lines of this:

// Database connection information
$connectionOptions = array(
    'driver' => 'pdo_mysql',
    'user' =>     $db['default']['username'],
    'password' => $db['default']['password'],
    'host' =>     $db['default']['hostname'],
    'dbname' =>   $db['default']['database']
);

// Create EntityManager
$this->em = EntityManager::create($connectionOptions, $doctrine_config);

When You would just configure a second entity manager with the other db, perhaps with a seperate doctrine-config:

// Database connection information
$connectionOptions2 = array(
    'driver' => 'pdo_mysql',
    'user' =>     $db['other']['username'],
    'password' => $db['other']['password'],
    'host' =>     $db['other']['hostname'],
    'dbname' =>   $db['other']['database']
);

// Create EntityManager
$this->emOther = EntityManager::create($connectionOptions2, $doctrine_config2);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜