note 71988 added to function.mysqli-stmt-num-rows
| From: | Typer85 at gmail dot com | Date: | Thu, 28 Dec 2006 00:12:34 +0000 |
| Subject: | note 71988 added to function.mysqli-stmt-num-rows | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-120968@lists.php.net to get a copy of this message | ||
Please be advised, for people who sometimes miss to read this important Manual entry for this
function:
If you do not use mysqli_stmt_store_result( ), and immediatley call this function after executing a
prepared statement, this function will usually return 0 as it has no way to know how many rows are
in the result set as the result set is not saved in memory yet.
mysqli_stmt_store_result( ) saves the result set in memory thus you can immedietly use this function
after you both execute the statement AND save the result set.
If you do not save the result set but still want to use this function you have to actually loop
through the result set one row at a time using mysqli_stmt_fetch( ) before using this function to
determine the number of rows.
A thought though, if you want to determine the number of rows without storing the result set and
after looping through it, why not just simply keep an internal counter in your loop every time a row
is fetched and save the function call.
In short, this function is only really useful if you save the result set and want to determine the
number of rows before looping through it, otherwise you can pretty much recreate its use like I
suggested.
----
Server IP: 66.163.161.117
Probable Submitter: 84.36.231.206
----
Manual Page -- http://www.php.net/manual/en/function.mysqli-stmt-num-rows.php
Edit -- https://master.php.net/note/edit/71988
Del: integrated -- https://master.php.net/note/delete/71988/integrated
Del: useless -- https://master.php.net/note/delete/71988/useless
Del: bad code -- https://master.php.net/note/delete/71988/bad+code
Del: spam -- https://master.php.net/note/delete/71988/spam
Del: non-english -- https://master.php.net/note/delete/71988/non-english
Del: in docs -- https://master.php.net/note/delete/71988/in+docs
Del: other reasons-- https://master.php.net/note/delete/71988
Reject -- https://master.php.net/note/reject/71988
Search -- https://master.php.net/manage/user-notes.php