PHP 复制代码
$db['default']['hostname']='localhost';$db['default']['username']='root';
$db['default']['password']='123456';
$db['default']['database']='mydb';
$db['default']['dbdriver']='pdo';
复制代码
代码如上图
浏览器访问,出错
Fatal error: Uncaught exception 'PDOException' with message 'invalid data source name' in D:\ci\system\database\drivers\pdo\pdo_driver.php on line 114
看看phpinfo.
PDO
PDO support
| enabled
|
PDO drivers | mysql, sqlite |
pdo_mysql PDO Driver for MySQL
| enabled
|
Client API version | mysqlnd 5.0.8-dev - 20102224 - $Revision: 321634 $ |
pdo_sqlite PDO Driver for SQLite 3.x
| enabled
|
SQLite Library | 3.7.7.1 |
pdo_mysql已经安装,没问题。gg 了一下database.php里面的代码应该这样写 PHP 复制代码
$db['default']['hostname']='mysql:host=localhost';
$db['default']['username']='root';
$db['default']['password']='123456';
$db['default']['database']='mydb';
$db['default']['dbdriver']='pdo';
复制代码
--转自