|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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)
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 13:00:02 2025 UTC |
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) }