mcbeav
mcbeav

Reputation: 12275

Any way to get the amount of rows returned using mysqli prepared statements?

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);

Upvotes: 1

Views: 836

Answers (2)

RabidFire
RabidFire

Reputation: 6330

Use this code:

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

Upvotes: 2

lonesomeday
lonesomeday

Reputation: 237995

Presuming you're doing something like:

$result = $statement->execute();

You can get the number of rows with

$result->num_rows;

See the manual.

Upvotes: 4

Related Questions