2 回答

TA贡献2080条经验 获得超4个赞
您没有声明驱动程序,因此您得到'could not find driver'。此外,您还缺少命名 host= 参数。
要纠正此错误,请像这样更改 PDO 实例化:
return new PDO(
'mysql:host='.$config['connection'].';dbname='.$config['name'],
$config['username'],
$config['password'],
$config['options']
);
您的$config数组没有问题,并且也被正确包含。</span>

TA贡献1815条经验 获得超10个赞
在 config.php 中,直接设置数组:
<?php
$config = [
'database' => [
'name' => 'schema_test',
'username' => 'name',
'password' => 'password',
'connection' => 'mysql:host=localhost:3306',
'options' => [],
]
];
在您的 bootstrap.php 中,请要求您的 config.php 文件如下:
require 'config.php';
并且不要忘记使用 $config['database']['name']...
- 2 回答
- 0 关注
- 203 浏览
添加回答
举报