gpt4 book ai didi

mysql - 我想将普通的 mysql 查询转换为 codeigniter

转载 作者:行者123 更新时间:2023-11-29 19:51:53 27 4
gpt4 key购买 nike

我想将普通的 mysql select 查询转换为 codeigniter

teacher_attendance 中选择 count(*) leave_statusteacher_id,其中 Teacher_id='1' & leave_status= “1”按 teacher_id

分组

这是我尝试过的

$attendance = $this->db->get_where('teacher_attendance', array('year' => $running_year, 'timestamp' => $timestamp, 'teacher_id' => $row['teacher_id']))->result_array();

我想要做的是通过教师id获取leave_status的计数

最佳答案

$this->db->select("count(*) as leave_status, teacher_id");
$this->db->from("teacher_attendance");
$this->db->where("teacher_id = 1 AND leave_status='1'");
$this->db->group_by("teacher_id");
$query = $this->db->get();
if ($query->num_rows() > 0) {
$result = $query->result_array();
}

关于mysql - 我想将普通的 mysql 查询转换为 codeigniter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40797455/

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