gpt4 book ai didi

php - 目前我得到了我的查询结果,但我想获得记录数

转载 作者:行者123 更新时间:2023-11-29 01:12:42 24 4
gpt4 key购买 nike

我想得到我的查询的计数,当前它显示所有记录

Controller :

 public function fetchCounts(){
$Result = $this->receivedModel->vehicleFreight($this->session->userdata('user_branch'));
}

型号:

public function vehicleFreight($branch_id)  
{
$this->db->select('*');
$this->db->from('truck_freight');
$this->db->where('truck_freight_status','truck_freight');
$this->db->where('fr_memo_to',$branch_id);

$query = $this->db->get();
return $query->result();
}

如何在查询中使用 count()。在我的数据库中,我有 3 条记录。

最佳答案

试试这个型号

public function vehicleFreight($branch_id)  
{
$this->db->select('count(*)');
$this->db->from('truck_freight');
$this->db->where('truck_freight_status','truck_freight');
$this->db->where('fr_memo_to',$branch_id);

$query = $this->db->get();
return $query->result();
}

关于php - 目前我得到了我的查询结果,但我想获得记录数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57820227/

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