Codeigniter:无法在我的库中加载数据库。 [英] Codeigniter : Cant load database in my library.
本文介绍了Codeigniter:无法在我的库中加载数据库。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试调用
When I try to call
$this->load->database();
产生以下错误在非对象上调用成员函数database()
自动加载数据库也无济于事...
当我尝试自动加载数据库时。
所有对数据库的调用,如
yields the following error `"Call to a member function database() on a non-object"
Autoloading the database doesnt help too...
when I try to autoload it.
all calls to database like
$this->db->get('people');
它说get方法未定义...
我不知道什么
where
任何人?
it says get method is undefined...
I have no clue what and where to start..
\
anyone ?
推荐答案
转到<$中的autoload.php c $ c> application / config / autoload.php 并添加此
$autoload['libraries'] = array('database'); // add database in array
请确保在应用程序中连接设置正确/config/database.php
比在库中这样做
Class MyLib
{
function getPeople(){
$CI = &get_instance();
$query = $CI->db->get('people');
return $query->result();
}
}
这篇关于Codeigniter:无法在我的库中加载数据库。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文