Req #38150 [Asn->Nab]: Please add row tell and seek for mysqli
| From: | johannes@php.net | Date: | Thu, 13 Apr 2017 13:38:25 +0000 |
| Subject: | Req #38150 [Asn->Nab]: Please add row tell and seek for mysqli | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-208526@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=38150&edit=1
ID: 38150
Updated by: johannes@php.net
Reported by: php at adaniels dot nl
Summary: Please add row tell and seek for mysqli
-Status: Assigned
+Status: Not a bug
Type: Feature/Change Request
Package: MySQLi related
Operating System: Any
PHP Version: 5.1.4
Assigned To: mysql
Block user comment: N
Private report: N
New Comment:
For seeking one has to buffer. Buffering in an array is most efficient as we can make use of
PHP's copy-on-write. Thus using fetch_all and then using the array is the best.
Previous Comments:
------------------------------------------------------------------------
[2011-01-16 01:18:09] kalle@php.net
From a "features complete" standpoint, I do not see why not add it, as it can achieve some
flexibility that a developer might need over the iterator and vice versa.
------------------------------------------------------------------------
[2011-01-06 15:03:44] uw@php.net
That's for buffered results only. I don't see a big win considering the iterator support
added rather recently (but not properly documented).
Johannes, what's your take?
------------------------------------------------------------------------
[2006-07-19 19:13:24] php at adaniels dot nl
I mean:
function get_all_rows(mysqli_result $result)
{
$ptr = $result->row_tell();
$rows = array();
$result->data_seek(0);
while ($row = $result->fetch_row()) $rows[] = $row;
$result->row_seek($ptr);
return $rows;
}
------------------------------------------------------------------------
[2006-07-19 19:06:42] php at adaniels dot nl
Description:
------------
The mysql API functions mysql_row_tell and mysql_row_seek are not ported to the mysqli libary.
I believe this is a shame, because currently it isn't possible to create a function which uses
a mysql_result but does not influence the code outside of the function.
I do not see the fact that, mysqli_row_seek would return a resource and not an actual rownumber, as
a problem.
P.S. If it is generaly agreed that this is a usefull feature, but there are no volenteers to add the
function, I volenteer myself.
Reproduce code:
---------------
I would like to do the following:
function get_all_rows(mysqli_result $result)
{
$ptr = $result->row_tell();
$rows = array();
while ($row = $result->fetch_row()) $rows[] = $row;
$result->row_seek($ptr);
return $rows;
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=38150&edit=1