2011-08-04 55 views

回答

2

我不確定您是否可以在兩個數據庫直接交互的情況下執行此操作。 (跨數據庫連接的/ etc ..)

但是在裝載了教義,你可能有沿此線的東西:

// 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); 

當你只配置第二個實體管理的其他數據庫,也許與一個獨立的教條配置:

// 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

謝謝,這有點幫助,我做,但是想要執行跨數據庫連接... – YTKColumba