how to get update status

I am trying to udpate a table using the table class
My code is -

$rs = array(“ref” => $ref);
$responsibility = new responsibility();
$resUpdate = $responsibility->update($rs,“id = '”.CurrentUserName().“’ AND ref IS NULL”);
if($resUpdate){ echo “Update Done”;}
else{ echo “Update not Done”;}

I want to echo “Update Done” when the udpate is successfully done
and “Update Not Done” When any update is not done.

Now my above code gets only “Update Done”.

You may try:

if ($resUpdate !== FALSE)

Getting the same result as above.

In the case 1 - One record is updated successfull and got the message “Update Done”
In the Case 2 - Zero record is updated (No row affected) and the same message is showing as “Update Done”

Note that “No row affected” is still successful execution of the SQL, the result of update() method is a recordset object, not number of records affected. To get the affected row count, you may use, e.g.

$rowcnt = ($resUpdate) ? $resUpdate->Affected_Rows() : 0;

arbei wrote:

$rowcnt = ($resUpdate) ? $resUpdate->Affected_Rows() : 0;

Got a error message as

Fatal error: Call to undefined method ADORecordSet_empty::Affected_Rows()

You may use the connection of the table class, e.g. try $responsibility->getConnection()->Affected_Rows() instead. (Assume v2020.)