How to make a static value in a dynamic query

Hello, this is my code and I want to make it dynamic, please provide me with a decision on how to do this.

$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;
}

I want to make this dynamic, how to make m using a query.

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

I don’t know if it is correct or not, but it displays an error

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

Help me how to do this. Thank.

+4
source share
1 answer
UPDATE `leave_applications` SET `days` = '0.5' WHERE `leave_type` = 3
+1
source

Source: https://habr.com/ru/post/1655826/


All Articles