PHP 8.5.0 Beta 1 available for testing

Voting

: min(six, one)?
(Example: nine)

The Note You're Voting On

ashteroid
5 years ago
To get the affected/selected row count from all queries

$q = "UPDATE `Review` SET `order` = 1 WHERE id = 600;" // aff 1
. "UPDATE `Review` SET `order` = 600 WHERE id = 1;" //aff 1
. "SELECT 0;" //for testing, aff rows == -1
;

$affcnt = 0;
$rowcnt = 0;

$res = $db->multi_query($q);
if($res == false)
Lib::throw( $q . "\n[" . $db->errno . "]\n" . $db->error . "\n" );
do
{
$affcnt += $db->affected_rows;
if( isset($res->num_rows) )
$rowcnt += $res->num_rows;
}
while( $db->more_results() && $res = $db->next_result() );
//IMPORTANT: call more_results First!, THEN next_result to get new data.

return $res;

<< Back to user notes page

To Top