为什么我出错?
请写正确的语法

您的SQL语法有误。检查与您的MySQL服务器版本相对应的手册以获取正确的语法,以在'IN,log_out_time作为OUT,hour_count作为小时,status作为状态使用
FROM(第1行的`hr_e'

SELECT `log_date` as DATE, `log_in_time` as IN, `log_out_time` as OUT, `hour_count` as Hours, `status` as Status
FROM (`hr_employee_attendence`)
WHERE `employee_id` =  '2001170036'
AND `log_date` >= '2017-11-01'
AND `log_date` <= '2017-11-30'

        $query = $this->db->select("log_date as DATE, log_in_time as IN, log_out_time as OUT, hour_count as Hours, status as Status")
                ->where($where)
                ->get("hr_employee_attendence");

最佳答案

您可以通过在下面的codeigniter链查询中使用关键字作为字符串。

$chain_query = $this->db->select("log_date as 'DATE', log_in_time as 'IN', log_out_time as 'OUT', hour_count as 'Hours', status as 'Status', is_late as is_late")
                            ->get_where("hr_employee_attendence", [
                                "employee_id" => $employee_id,
                                "date(log_date) >= date('".$month_day_start."')" => NULL,
                                "date(log_date) <= date('".$month_day_end."')" => NULL,
                                "is_approved" => 1
                            ]);

关于mysql - codeigniter链查询关键字问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47494811/

10-09 22:22