我收到此错误"致命错误:当我尝试使用我的某个模型时,调用未定义的方法CI_DB_mysql_driver :: findVenueInfo()".
我有这个锚的视图:
echo anchor('welcome/searchVenue/' . $row->venue_id, $row->venue);
Run Code Online (Sandbox Code Playgroud)
它生成如下链接:http://localhost/ci-llmg/index.php/welcome/searchVenue/1
调用的方法是
function searchVenue()
{
$this->load->model('venues');
//get venue info
$data['info'] = $this->venues->findVenueInfo($this->uri->segment(3)); //this line generates the error
}
Run Code Online (Sandbox Code Playgroud)
并且模型中的findVenueInfo函数(venues.php)是:
function findVenueInfo($id)
{
$data = array();
$this->db->where('id', $id);
$Q = $this->db->get('venues');
if ($Q->num_rows() > 0)
{
foreach ($Q->result() as $row)
{
$data[] = $row;
}
}
$Q->free_result();
return $data;
}
Run Code Online (Sandbox Code Playgroud)
..但结果是致命错误:调用未定义的方法CI_DB_mysql_driver :: findVenueInfo()我可能错过了一些愚蠢的东西,但无法让它工作!你怎么看?
您确定您index.php的项目根目录中的文件已包含在适当位置的引导程序
转到index.php文件的末尾并在包含之前包含引导程序文件codeigniter.php.
您的index.php文件的结尾行应如下所示.
/*
* --------------------------------------------------------------------
* LOAD THE BOOTSTRAP FILE
* --------------------------------------------------------------------
*
* And away we go...
*
*/
require_once APPPATH.'third_party/datamapper/bootstrap.php';
require_once BASEPATH.'core/CodeIgniter.php';
Run Code Online (Sandbox Code Playgroud)