Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A good way to get feedback on database updates
#1
I didn't know about this until I was searching for it in Peardatabase.php:

When you do an UPDATE query and you want to find out if all went well, you can use the 'getAffectedRowCount' method of the '$adb' object. This will give you the number of affected rows which will tell you if at least one row was affected. Use your query result object as a parameter:

PHP Code:
$result $this->db->pquery($query$params);
if (
$this->db->getAffectedRowCount($result) >= 1) {
   return 
true;
} else {
  return 
false;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)