解決的辦法是這樣做的index.php中:
Doo::loadCore('db/DooSqlMagic');
$db = new DooSqlMagic;
$db->setDb($dbconfig, 'db'.$config['APP_MODE']);
$db->connect();
$db2 = new DooSqlMagic;
$db2->setDb($dbconfig, 'db2'.$config['APP_MODE']);
$db2->connect();
這db.conf.php:
$dbconfig['dbdev'] = array('localhost', 'db', 'root', '', 'mysql', true, 'collate'=>'utf8_unicode_ci', 'charset'=>'utf8');
$dbconfig['dbprod'] = array('localhost', 'db', 'root', '', 'mysql', true, 'collate'=>'utf8_unicode_ci', 'charset'=>'utf8');
$dbconfig['db2dev'] = array('localhost', 'db2', 'root', '', 'mysql', true, 'collate'=>'utf8_unicode_ci', 'charset'=>'utf8');
$dbconfig['db2prod'] = array('localhost', 'db2', 'root', '', 'mysql', true, 'collate'=>'utf8_unicode_ci', 'charset'=>'utf8');
並在控制器使用這樣的:
global $db;
global $db2;
$db->query('.......');
$db2->query('......');
你有沒有試圖將數據庫名稱特定到SQL?假設所有數據庫都在同一個主機上,在相同的端口上偵聽,相同的用戶對這兩個數據庫具有相同的權限 – ajreal 2011-06-17 14:47:49