简体   繁体   中英

Codeigniter cannot get data from mysql table

I get following error while trying to get data from my database:

Error Number: 1066

Not unique table/alias: 'faq'

SELECT *FROM ( faq , faq )WHERE faq_title = 'title 1'

Please help me to find my mistake. Here is my model:

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;
    }
   }   

In your query table name is called two times. This is unnecessary. Just replace $query = $this->db->get('faq'); to $query = $this->db->get(); the bold one is correct.

public function 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;
}

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM