gpt4 book ai didi

php - 无法使用 codeigniter 查询计算有条件的结果

转载 作者:行者123 更新时间:2023-11-29 04:24:32 25 4
gpt4 key购买 nike

我正在尝试计算以 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com