Gena
Posts: 591
|
Posted: 03/21/2011, 11:01 AM |
|
We are often interested to know how many records the query affected or updated when you use direct DB operation. The function affected_rows() will return the number of rows or records affected by any update, insert or delete query.
For example, if you UPDATE some table you can use following code:
$dbr = new clsDBmydatabaseDB();
$rate = 1.5;
$SQLr = "update ProductPrice set ProductPriceRate=" . $rate . " where ProductPriceCurrency='USD'" ;
$dbr->query($SQLr);
$num = $dbr->affected_rows() ; // $num contains number of affected records
$dbr->close();
_________________
Gena |