我的模型作者功能是这样的
class Authors extends CI_Model{
function __construct()
{
parent::__construct();
}
function available_username($text)
{
$this->db->query("SELECT username FROM tbl_users WHERE username='$text' LIMIT 1");
if($this->db->affected_rows() == 0)
{
return TRUE;
}
else
{
return FALSE;
}
}
}
我在我的课堂上这样调用这个函数
$CI =& get_instance();
$CI->load->model('authors');
$username = "Danny";
if($CI->authors->available_username($username) == TRUE)
{
$fUsername = TRUE;
}
else
{
$fUsername = FALSE;
}
我认为这是正确的方法,但我得到了模型错误
Fatal error: Call to a member function query() on a non-object