作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想同时连接和运行 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 数据库片段,但它不起作用。未找到我来自“系统”的数据。
抱歉我的英语不好。
数据库.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'];
最佳答案
您将数据库数组定义为“default”中的“default”,第二个定义为“default”中的“test”。
我使用了不同的数组结构:
“默认”里面的“默认”和“测试”中的“默认”这对我有用,所以尝试将第二个数据库定义更改为:
$databases['test']['default'] = array(
关于php - 德鲁帕尔 7 : Connect & Run 2 MySQL simultaneously,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44881324/
我是一名优秀的程序员,十分优秀!