我想将普通的mysql select查询转换为codeigniter
SELECT count(*)leave_status
,teacher_id
FROM teacher_attendance
WHERE 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的数量答案 0 :(得分:0)
$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();
}