簡體   English   中英

Codeigniter無法從mysql表獲取數據

[英]Codeigniter cannot get data from mysql table

嘗試從數據庫中獲取數據時出現以下錯誤:

錯誤號:1066

不是唯一的表格/別名:“常見問題解答”

SELECT * FROM( faqfaq )其中faq_title ='title 1'

請幫助我找到我的錯誤。 這是我的模型:

public function did_get_faq_data($title){

    $this->db->select('*');
    $this->db->from('faq');   
    $this->db->where('faq_title', $title); 

    $query = $this->db->get('faq');

    if ($query->num_rows() > 0){
    return $query->result();
    }
    else {
    return false;
    }
   }   

在查詢表中,該名稱被調用了兩次。 這是不必要的。 只需替換$ query = $ this-> db-> get('faq'); $ query = $ this-> db-> get(); 大膽的是正確的。

公共功能did_get_faq_data($ title){

$this->db->select('*');
$this->db->from('faq');   
$this->db->where('faq_title', $title); 

$query = $this->db->get();

if ($query->num_rows() > 0){
return $query->result();
}
else {
return false;
}

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM