php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #38150 Please add row tell and seek for mysqli
Submitted: 2006-07-19 19:06 UTC Modified: 2017-04-13 13:38 UTC
Votes:2
Avg. Score:4.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:2 (100.0%)
From: php at adaniels dot nl Assigned: mysql (profile)
Status: Not a bug Package: MySQLi related
PHP Version: 5.1.4 OS: Any
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php at adaniels dot nl
New email:
PHP Version: OS:

 

 [2006-07-19 19:06 UTC] 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;
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-19 19:13 UTC] 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;
}
 [2011-01-01 23:40 UTC] jani@php.net
-Package: Feature/Change Request +Package: MySQLi related
 [2011-01-06 15:03 UTC] uw@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: mysql
 [2011-01-06 15:03 UTC] 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?
 [2011-01-16 01:18 UTC] 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.
 [2017-04-13 13:38 UTC] johannes@php.net
-Status: Assigned +Status: Not a bug
 [2017-04-13 13:38 UTC] johannes@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 14 17:01:25 2024 UTC