I just want to know if there are any funcitons that can find the total length of the records the DBA function fetch from the DB file. Thanks a lot!
2条回答 默认 最新
ds11111111111111111 2012-07-31 22:27关注If you are using PDO, you can use get the number of rows via:
<?php $qry = $dbh->prepare('select * FROM fruit'); $del->execute(); $count = $qry->rowCount(); print("Found $count rows. "); ?>You can also get the number of rows is you are using mysqli like this:
<?php // yada yada $result = $mysqli->query("SELECT Code, Name FROM Country ORDER BY Name"); $row_cnt = $result->num_rows; printf("Result set has %d rows. ", $row_cnt); ?>Be aware that this one won't return the number of rows when your query is an insert, delete, update or replace. You would need to use the affected rows for that.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报