我正在关注Destructy教程,在设置和测试数据库连接后,我收到以下错误:
到目前为止,这是我的设置:
fixed
这是容器的定义方式:
begin
page.driver.browser.navigate.to("about:blank")
page.driver.browser.switch_to.alert.accept
rescue Selenium::WebDriver::Error::NoAlertPresentError
# No alert was present. Don't need to do anything
end
路线:
return [
'settings' => [
'displayErrorDetails' => true,
],
'url' => 'http://localhost',
'db' => [
'mysql' => [
'host' => 'localhost',
'dbname' => 'destructy',
'username' => 'username',
'password' => 'password',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
]
],
];
有人知道问题是什么来修复它吗?
答案 0 :(得分:1)
您无法使用点语法访问配置值,应该类似于:
$container['db'] = function($c){
$conf = $c->db;
return new PDO(
'mysql:host='.$conf['mysql']['host'].';dbname='.$conf['mysql']['dbname'],
$conf['mysql']['username'],
$conf['mysql']['password'];
};