So I am just trying to run an update query using codeigniter using an array. Here is my code
$array = array('departmentID' => $departmentID);
$this->db->where($array);
$data = array(
"pending" => "pending+".$pendingNew,
"approved" => "approved+".$approvedNew,
"notApproved" => "notApproved+".$notApprovedNew
);
$this->db->update('departments', $data);
It is running fine and not giving any errors but it is not updating the database, so I tried printing out the generated query like this
echo $this->db->last_query();
And it gives me the following
UPDATE `departments` SET `pending` = 'pending+2', `approved` = 'approved+6', `notApproved` = 'notApproved+0' WHERE `departmentID` = '10';
So I believe the problem is because it is putting the apostophes around the addition part as when I remove those and just run the sql as the floowing it updates coreectly.
UPDATE `departments` SET `pending` = pending+2, `approved` = approved+6, `notApproved` = notApproved+0 WHERE `departmentID` = '10'
Can anyone tell me how I can fix this?