gpt4 book ai didi

php - 具有事件记录的 CodeIgniter COUNT?

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

我在 codeigniter 工作..我想数一数。具有相同 order_no 的行数。下面是我的代码。

public function get_my_orders() {
$user_data = $this->session->all_userdata();
$email = $user_data['user_email'];
$this->db->select('*');
$this->db->from('order_details');
$this->db->where('email', $email);
$this->db->group_by('order_no');
$this->db->order_by('order_no', 'DESC');
$query = $this->db->get();
return $query->result();
}

请帮忙..

最佳答案

您可以使用 $this->db->count_all_results()

 public function get_my_orders() {
$user_data = $this->session->all_userdata();
$email = $user_data['user_email'];
//$this->db->select('*');// no need select as you only want counts
$this->db->from('order_details');
$this->db->where('email', $email);
//$this->db->group_by('order_no');//no need group_by as you only want counts
//$this->db->order_by('order_no', 'DESC');//no need order_by as you only want counts
return $this->db->count_all_results();;
}

关于php - 具有事件记录的 CodeIgniter COUNT?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28512828/

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