When I try this code:
$query = '';
foreach ($data as $row)
{
$where = array(
'community_id' => $row->id,
'user_id' => $this->session->user_id,
'status' => 'invited_to_join',
);
$update = array(
'status' => 'joined',
);
$query .= $this->db->set($update)->where($where)->get_compiled_update('community_members') . '; ';
}
if ($query)
{
return $this->db->query($query);
}
it gives me the error:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UPDATE `community_members` SET `status` = 'joined' WHERE `community_id` = '18' A' at line 4
this answer uses a straightforward query with CASE, but I don't know how to convert that into CodeIgniter's query builder.