I have two functions in my model. First one:
public function updateOwn($game,$own,$user) {
$data = array(
'own' => $own
);
$q = $this->db->where(array(
'game' => $game,
'user' => $user
));
$q = $this->db->update('ownership',$data);
if($q) { return true; } else { return false; }
}
and the secound one:
public function updateRate($game,$rate,$user) {
$data = array(
'rate' => $rate
);
$q = $this->db->where(array(
'game' => $game,
'user' => $user
));
$q = $this->db->update('rates',$data);
$q = $this->db->update('ownership',$data);
if($q) { return true; } else { return false; }
}
The problem is, first one is working, secound one isn’t. I mean, it works, but it updates every row, not just those with matching game and user. Variables are passed fine.
The where condition is only applied to the first update statement. Try below.