[英]Codeigniter cannot get data from mysql table
I get following error while trying to get data from my database: 尝试从数据库中获取数据时出现以下错误:
Error Number: 1066 错误号:1066
Not unique table/alias: 'faq' 不是唯一的表格/别名:“常见问题解答”
SELECT *FROM ( faq
, faq
)WHERE faq_title
= 'title 1' SELECT * FROM( faq
, faq
)其中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'); 只需替换$ query = $ this-> db-> get('faq'); to $query = $this->db->get(); 到$ query = $ this-> db-> get(); the bold one is correct. 大胆的是正确的。
public function did_get_faq_data($title){ 公共功能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.