I have a model function that updates a user in my CodeIgniter application:
// updates first of a user, return true if successful, false if not.
public function updateFirstName($userId, $newFirstName) {
$this->db->query("UPDATE users SET firstName='$newFirstName' WHERE id=$userId");
return // whether request was successful?
}
How do I return a boolean value that ensures the user of ID $userId
has been updated? For instance, it should return false if no user was found with ID $userId
.
As commented, have you tried $this->db->affected_rows()
?
That will tell you how many rows were updated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With