php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37340 can't fetch cursor position in PDOStatement::fetch
Submitted: 2006-05-06 18:03 UTC Modified: 2006-06-25 16:17 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: nowelium at gmail dot com Assigned: iliaa (profile)
Status: Closed Package: PDO related
PHP Version: 5.1.4 OS: SuSE Linux 10.0
Private report: No CVE-ID: None
 [2006-05-06 18:03 UTC] nowelium at gmail dot com
Description:
------------
When using PDO for simple query for PostgreSQL(8.0.3) and MySQL(5.0.18)

cannot acquire it though I want to acquire the offset of the specified cursor.
and, fetch() is next offset  acquired when acquiring it.

The referred sample is manual://function.pdostatement-fetch.php

in DB
 empno | ename  |    job    | mgr  |  hiredate  |   sal   |  comm   | deptno
-------+--------+-----------+------+------------+---------+---------+--------
  7369 | SMITH  | CLERK     | 7902 | 1980-12-17 |  800.00 |         |     20
  7499 | ALLEN  | SALESMAN  | 7698 | 1981-02-20 | 1600.00 |  300.00 |     30
  7521 | WARD   | SALESMAN  | 7698 | 1981-02-22 | 1250.00 |  500.00 |     30
  7566 | JONES  | MANAGER   | 7839 | 1981-04-02 | 2975.00 |         |     20
  7654 | MARTIN | SALESMAN  | 7698 | 1981-09-28 | 1250.00 | 1400.00 |     30

Reproduce code:
---------------
// mysql:host=localhost; dbname=foodb
$dbh = new PDO("pgsql:host=localhost; dbname=foodb", $user, $pass);
$stmt = $dbh->prepare("SELECT * FROM EMP ORDER BY EMPNO", array(PDO::ATTR_CURSOR, PDO::CURSOR_SCROLL));
$stmt->execute();
var_dump($stmt->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_ABS, 3));
var_dump($stmt->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_REL, 1));

Expected result:
----------------
array(8) {
  ["empno"]=>
  int(7369)
  ["ename"]=>
  string(5) "SMITH"
  ["job"]=>
  string(5) "CLERK"
  ["mgr"]=>
  int(7902)
  ["hiredate"]=>
  string(10) "1980-12-17"
  ["sal"]=>
  string(6) "800.00"
  ["comm"]=>
  NULL
  ["deptno"]=>
  int(20)
}
array(8) {
  ["empno"]=>
  int(7499)
  ["ename"]=>
  string(5) "ALLEN"
  ["job"]=>
  string(8) "SALESMAN"
  ["mgr"]=>
  int(7698)
  ["hiredate"]=>
  string(10) "1981-02-20"
  ["sal"]=>
  string(7) "1600.00"
  ["comm"]=>
  string(6) "300.00"
  ["deptno"]=>
  int(30)
}

Actual result:
--------------
array(8) {
  ["empno"]=>
  int(7566)
  ["ename"]=>
  string(5) "JONES"
  ["job"]=>
  string(7) "MANAGER"
  ["mgr"]=>
  int(7839)
  ["hiredate"]=>
  string(10) "1981-04-02"
  ["sal"]=>
  string(7) "2975.00"
  ["comm"]=>
  NULL
  ["deptno"]=>
  int(20)
}
array(8) {
  ["empno"]=>
  int(7654)
  ["ename"]=>
  string(6) "MARTIN"
  ["job"]=>
  string(8) "SALESMAN"
  ["mgr"]=>
  int(7698)
  ["hiredate"]=>
  string(10) "1981-09-28"
  ["sal"]=>
  string(7) "1250.00"
  ["comm"]=>
  string(7) "1400.00"
  ["deptno"]=>
  int(30)
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-06 18:09 UTC] nowelium at gmail dot com
sorry... It was opposite ..not breathing in... 

Expected result:
----------------
array(8) {
  ["empno"]=>
  int(7566)
  ["ename"]=>
  string(5) "JONES"
  ["job"]=>
  string(7) "MANAGER"
  ["mgr"]=>
  int(7839)
  ["hiredate"]=>
  string(10) "1981-04-02"
  ["sal"]=>
  string(7) "2975.00"
  ["comm"]=>
  NULL
  ["deptno"]=>
  int(20)
}
array(8) {
  ["empno"]=>
  int(7654)
  ["ename"]=>
  string(6) "MARTIN"
  ["job"]=>
  string(8) "SALESMAN"
  ["mgr"]=>
  int(7698)
  ["hiredate"]=>
  string(10) "1981-09-28"
  ["sal"]=>
  string(7) "1250.00"
  ["comm"]=>
  string(7) "1400.00"
  ["deptno"]=>
  int(30)
}

Actual result:
--------------
array(8) {
  ["empno"]=>
  int(7369)
  ["ename"]=>
  string(5) "SMITH"
  ["job"]=>
  string(5) "CLERK"
  ["mgr"]=>
  int(7902)
  ["hiredate"]=>
  string(10) "1980-12-17"
  ["sal"]=>
  string(6) "800.00"
  ["comm"]=>
  NULL
  ["deptno"]=>
  int(20)
}
array(8) {
  ["empno"]=>
  int(7499)
  ["ename"]=>
  string(5) "ALLEN"
  ["job"]=>
  string(8) "SALESMAN"
  ["mgr"]=>
  int(7698)
  ["hiredate"]=>
  string(10) "1981-02-20"
  ["sal"]=>
  string(7) "1600.00"
  ["comm"]=>
  string(6) "300.00"
  ["deptno"]=>
  int(30)
}
 [2006-06-25 16:17 UTC] nowelium at gmail dot com
misunderstand
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 24 09:01:31 2024 UTC