CodeIgniter中的PDO数据库配置是什么? [英] What is PDO database configuration in CodeIgniter?

查看:58
本文介绍了CodeIgniter中的PDO数据库配置是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

application / config / database.php 中,为了设置最佳数据库配置,应设置 $ db ['default'] ['主机名'] =''; 'localhost'通过使用mysql驱动程序。

In application/config/database.phpfor setting up a optimal database configuration should set the $db['default']['hostname'] = ''; to 'localhost' by use of mysql driver.

但是当我们使用PDO驱动程序进行此配置,使用localhost作为主机名时,会看到ERROR。

But when we use PDO driver for this configuration and localhost for the host name we see ERROR. What is PDO database hostname configuration in CodeIgniter with PDO driver shown below and what should place instead of question mark?

$db['default']['hostname'] = '?????';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'XXX';
$db['default']['dbdriver'] = 'PDO';


推荐答案

如果您尝试连接pdo,请尝试使用codeigniter 3

If your trying to connect pdo try in codeigniter 3

$db['default'] = array(
'dsn'  => 'mysql:host=localhost; dbname=myproject; charset=utf8;',
'hostname' => 'localhost',
'username' => 'root',
'password' => '*********',
'database' => '',
'dbdriver' => 'pdo',

这篇关于CodeIgniter中的PDO数据库配置是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆