php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79940 Cannot re-fetch rows in PDO
Submitted: 2020-08-06 22:03 UTC Modified: 2020-08-09 12:13 UTC
From: guana dot histark at gmail dot com Assigned: cmb (profile)
Status: Duplicate Package: PDO MySQL
PHP Version: 8.0.0beta1 OS: Linux
Private report: No CVE-ID: None
 [2020-08-06 22:03 UTC] guana dot histark at gmail dot com
Description:
------------
PDO::FETCH_ORI_ABS is not working for mariadb

Test script:
---------------
while($row = $stmt->fetch(PDO::FETCH_ASSOC,PDO::FETCH_ORI_ABS,0))


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-08-06 22:17 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2020-08-06 22:17 UTC] requinix@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2020-08-07 05:42 UTC] guana dot histark at gmail dot com
-Status: Feedback +Status: Open
 [2020-08-07 05:42 UTC] guana dot histark at gmail dot com
<?php

$stmt = $conn->prepare("SELECT 1 FROM TABLE WHERE ID = 1");
$stmt->execute();

while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
   echo "First fetch \n";
}

while($row = $stmt->fetch(PDO::FETCH_ASSOC,PDO::FETCH_ORI_ABS,0)){
   echo "Second fetch \n";
}

?>
 [2020-08-07 13:40 UTC] cmb@php.net
$stmt = $conn->prepare("SELECT 1 FROM TABLE WHERE ID = 1");

should likely be

$stmt = $conn->prepare("SELECT 1 FROM TABLE WHERE ID = 1", [PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL]);
 [2020-08-07 22:17 UTC] guana dot histark at gmail dot com
I tried with [PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL]

But it the bug still persist.
 [2020-08-09 12:10 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2020-08-09 12:10 UTC] cmb@php.net
I noticed that this is actually a duplicate of bug #63466.
 [2020-08-09 12:13 UTC] guana dot histark at gmail dot com
Yes, I have seen that too. But have not been fix since. Its PHP 8 now in beta :)
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Aug 02 23:01:23 2021 UTC