我正在尝试计算以 display_id 作为参数的 bookdetails 表的行数。假设我通过了 $id='3'
。但我没有得到输出。
我认为我正在尝试的代码是错误的。请帮助我正确编写此查询
//--- Counting the rows of bookdetails of table where display_id is as argument-------------------------------------------------------------
public function record_count_for_secondtopBooks($id) {
$this->load->database();
return $this->db->count_all("bookdetails",array('display_id'=>$id));
}
最佳答案
count_all 返回特定行数
echo $this->db->count_all('my_table');
试试这个
$this->db->where('display_id', $id);
$this->db->from('bookdetails"');
$this->db->count_all_results();
关于php - 无法使用 codeigniter 查询计算有条件的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14622426/