php – 如何在动态查询中创建静态值

您好,这是我的代码,我想让它动态,请为我提供一个如何做到这一点的解决方案.

$start = strtotime($this->input->post('leave_from'));
$end = strtotime($this->input->post('leave_to'));
$days_between = ceil(abs($end - $start) / 86400 + 1);

if($this->input->post('leave_type') == 3){
    $days_between = 0.5;
}

我想让这个动态如何使用查询.

$q = "set leave_applications.days = '0.5' on leave_applications where leave_type = 3 "; 
$days_between = $this->leave_application_model->q_single($q);

不知道它是否正确但是它显示错误

Unknown system variable ‘days’ set leave_applications.days = ‘0.5’ on
leave_applications where leave_type = 3

帮帮我怎么做.
谢谢.

最佳答案

UPDATE `leave_applications` SET `days` = '0.5' WHERE `leave_type` = 3
点赞