【发布时间】:2017-07-03 08:50:59
【问题描述】:
我想同时连接并运行 2 个数据库,因为我希望我的 CMS 从其他数据库中读取一些数据。有没有办法运行它?
我的设置.php
$databases = array();
$databases['default']['default'] = array(
'driver' => 'mysql',
'database' => 'portal',
'username' => 'root',
'password' => 'root',
'host' => 'localhost',
'prefix' => 'drupal_',
);
$databases['default']['test'] = array(
'driver' => 'mysql',
'database2' => 'systems',
'username' => 'root',
'password' => 'root',
'host' => 'localhost',
'prefix' => '',
);
我尝试更改 drupal db sn-p 但它不起作用。未找到来自“系统”的数据。
对不起,我的英语不好。
数据库.inc
// Character set is added to dsn to ensure PDO uses the proper character
// set when escaping. This has security implications. See
// https://www.drupal.org/node/1201452 for further discussion.
$dsn .= ';charset=' . $charset;
$dsn .= ';dbname=' . $connection_options['database']['database2'];
【问题讨论】: