Any way to get the amount of rows returned using m

2019-08-04 17:28发布

问题:

Wondering if there is a way to get the amount of rows returned from a query using mysqli prepared statements, sort of like

mysql_num_rows($query);

回答1:

Presuming you're doing something like:

$result = $statement->execute();

You can get the number of rows with

$result->num_rows;

See the manual.



回答2:

Use this code:

$result = $mysqli->query($query);
$num_rows = $result->num_rows($result);