我刚刚从他们的网站(版本3.0.3)下载了CI的新副本,只是配置了数据库并加载了它,但我遇到了错误。
以下是config.php中的数据库配置
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'shortagesdb',
'dbdriver' => 'mysql',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => TRUE,//(ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
这就是我在控制器中所做的事情,只需加载数据库
public function index()
{
$this->load->database();
$this->load->view('welcome_message');
}
这里没什么好看的,无论什么
我都会得到这个例外PHP Fatal error: Call to undefined function mysql_connect() in D:\Projects\ims\system\database\drivers\mysql\mysql_driver.php on line 136
任何帮助都将受到高度赞赏
答案 0 :(得分:3)
Codeigniter 3不支持MySQL。 MySQL is deprecated in version 3.0 强>
试试这个
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root', # check username
'password' => '', # check password
'database' => 'shortagesdb', # check DB name is correct
'dbdriver' => 'mysqli', # remove mysql
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'), # remove TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
答案 1 :(得分:1)
问题可能在你的php.ini文件中,转到你的php文件夹并在文本编辑器中打开该文件。现在找到扩展并取消注释:
extension=php_mysqli.dll
还要检查扩展路径是否正确定向到php根位置的ext文件夹。