|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Submitted: 2007-04-17 06:49 UTC Modified: 2016-09-12 22:14 UTC
Avg. Score:3.8 ± 0.7
Reproduced:4 of 4 (100.0%)
Same Version:2 (50.0%)
Same OS:0 (0.0%)
From: danil dot megrabjan at gmail dot com Assigned:
Status: Wont fix Package: PDO DBlib
PHP Version: 5.2.1 OS: sles 10
Private report: No CVE-ID: None
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
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=;dbname=db', 'user', 'password', array(PDO::ATTR_PERSISTENT => true));

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

$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


Add a Patch

Pull Requests

Add a Pull Request


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]
-Package: PDO_DBLIB +Package: PDO related
 [2014-01-01 12:42 UTC]
-Package: PDO related +Package: PDO DBlib
 [2014-10-25 04:33 UTC]
-Assigned To: +Assigned To: ssufficool
 [2016-06-26 18:15 UTC]
-Assigned To: ssufficool +Assigned To:
 [2016-09-12 22:14 UTC]
-Status: Open +Status: Wont fix -Type: Bug +Type: Feature/Change Request
 [2016-09-12 22:14 UTC]
pdo_dblib doesn't support scrollable cursors, so this would be a feature request. DB-Library doesn't exactly support them either. The closest thing it offers are row buffers. It might be possible to approximate this functionality with them, but the API semantics are a little different. For one thing, you have to declare a buffer size. Since use cases likely vary, it might be better to handle this at a higher level.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 15 09:01:28 2024 UTC