Hi All.
Have been messing around with PDO for a while, but have come across a bit of a quandry. I like the prepare - execute method for fetching data, but I needed to check if an update query actually did update or not. Now not having mysql_affected_rows() to hand, I was left scratching my head. PDO:exec can do this, but it seems only on 'straight unprepared queries'. Does anybody here have any suggestions on the best way to implement a PDO::exec but on a prepared query?
This is some cut-down of my code, so you get the idea:
public function setEmail($newemail){
$statement = $this->db->prepare("UPDATE users SET email = :email WHERE user_id = :id");
$statement->execute(array(':email' => $newemail, ':id' => $this->id));
}
Now, I'm looking to do something like this:
$count = $this->db->exec("UPDATE users SET email = '$newemail' WHERE user_id = $this->id");
return $count;
But parameterized/prepared. Any thoughts gratefully received.