php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57623 PDO::FETCH_ORI_LAST & PDO::FETCH_ORI_PRIOR
Submitted: 2007-04-17 06:49 UTC Modified: 2014-01-01 12:42 UTC
Votes:2
Avg. Score:4.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:0 (0.0%)
From: danil dot megrabjan at gmail dot com Assigned:
Status: Open Package: PDO DBlib
PHP Version: 5.2.1 OS: sles 10
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-04-17 06:49 UTC] danil dot megrabjan at gmail dot com
Description:
------------
I have a mssql table. 
Something like this:

id | field1
-----------
1  | a
2  | b
3  | c
-----------

I want to move backward (from last to first), in my PDOStatment. But...

Reproduce code:
---------------
$db = new PDO('dblib:host=192.168.1.3:1433;dbname=db', 'user', 'password', array(PDO::ATTR_PERSISTENT => true));

$stmt = $db->prepare('select * from table', array(PDO::ATTR_CURSOR, PDO::CURSOR_SCROLL));
$stmt->execute();

$row = $stmt->fetch(PDO::FETCH_BOTH, PDO::FETCH_ORI_LAST);

while ($row = $stmt->fetch(PDO::FETCH_BOTH, PDO::FETCH_ORI_PRIOR)) {
  print $row[0] . "\t" . $row[1] . "\n";
}

$stmt = null;
?>

Expected result:
----------------
-------
3  | c
2  | b
1  | a
-------

Actual result:
--------------
-------
1  | a
2  | b
3  | c
-------

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-02-10 11:15 UTC] shol_ at hotmail dot com
I've a similar problem with PDO::FETCH_ORI_LAST as you have,
in my case I only want the last entry from the resultset, but 
PDO::FETCH_ORI_LAST fetches the first one.

If I fetch an x number of other entries with PDO::FETCH_ORI_PRIOR, after PDO::FETCH_ORI_LAST, then it spits out the same results as if I were doing an fetchAll().

Did you find an efficient workaround ?

I use  the same php version, but on ubuntu 9.1.

This is the only post on internet AFAIK, about this bug.
 [2013-06-12 01:51 UTC] ssufficool@php.net
-Package: PDO_DBLIB +Package: PDO related
 [2014-01-01 12:42 UTC] felipe@php.net
-Package: PDO related +Package: PDO DBlib
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 17 06:02:13 2014 UTC