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

狂风中的少年 提交于 2019-12-12 23:33:21

问题


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


来源:https://stackoverflow.com/questions/4607487/any-way-to-get-the-amount-of-rows-returned-using-mysqli-prepared-statements

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!