使用Codeigniter加载数据库时,我在一个加载数据库的简单文件中收到以下错误消息:
An Error Was Encountered
Unable to load the requested class: database
此代码的控制器名为db.php,其代码如下:
<?php
class Db extends MY_Controller {
function __construct() {
parent::__construct();
$this->load->library('database');
}
public function index() {}
}
我没有将数据库加载到autoload.php中。我也知道我的config.php文件中有正确的数据库信息。如果可能导致任何问题,我的CodeIgniter应用程序位于子域中。
关于可能导致问题的任何想法?感谢。
答案 0 :(得分:9)
使用$this->load->database();
而不是$this->load->library('database');