2010-04-02 118 views
3

當我嘗試使用我的某個模型時,出現此錯誤「致命錯誤:調用未定義方法CI_DB_mysql_driver :: findVenueInfo()」。Codeigniter - 調用未定義的方法CI_DB_mysql_driver ::

我有此錨的圖:

echo anchor('welcome/searchVenue/' . $row->venue_id, $row->venue); 

產生像一個鏈接: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 

} 

和在模型中findVenueInfo功能(場地.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; 
} 

..但是這樣做的結果是致命錯誤:調用未定義的方法CI_DB_mysql_driver :: findVenueInfo() 我可能錯過了一些愚蠢的東西,但無法讓它工作!你怎麼看?

+0

固定 - 我知道這是愚蠢的東西:) 的控制器使用$ this-> db-> findVenueInfo而不是$ this-> venue-> findVenueInfo。 – Patrick 2010-04-02 15:38:31

回答

3
function findVenueInfo($id) 
{ 
    $data = array(); 
    $this->db->select()->from('venues')->where('id', $id);<----change it to 

    $Q = $this->db->get();<----change it to 
    if ($Q->num_rows() > 0) 
    { 
     foreach ($Q->result() as $row) 
     { 
      $data[] = $row; 
     } 
    } 

    $Q->free_result(); 
    return $data; 
} 
+0

函數findVenueInfo($ id){ $ data = array(); $ this-> db-> select() - > from('venues') - > where('id',$ id); <----將其更改爲 $ Q = $ this-> db-> get(); <----如果($ Q-> num_rows()> 0)將其更改爲 foreach($ Q-> result()as $ row) { $ data [] = $行; } } $ Q-> free_result(); 返回$ data; } – raulb 2010-06-29 12:18:39

+0

考慮不在灰色背景下的第一行 – raulb 2010-06-29 12:19:38

5

你確定你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'; 
+3

mysql驅動程序錯誤與bootstrap有什麼關係? – Zeeshan 2016-11-18 08:42:18

2

我得到一個類似的錯誤,結果發現,3.0我需要能夠在應用query_builder /配置/ database.php中

$query_builder = TRUE; 
相關問題