#42917 [Asn->Csd]: PDO::FETCH_KEY_PAIR doesn't work with setFetchMode
| From: | iliaa@php.net | Date: | Thu, 11 Oct 2007 20:58:36 +0000 |
| Subject: | #42917 [Asn->Csd]: PDO::FETCH_KEY_PAIR doesn't work with setFetchMode | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-118426@lists.php.net to get a copy of this message | ||
ID: 42917
Updated by: iliaa@php.net
Reported By: remi dot lanvin at bsocom dot com
-Status: Assigned
+Status: Closed
Bug Type: PDO related
Operating System: Linux 2.6.17.8
PHP Version: 5.2.4
Assigned To: iliaa
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2007-10-10 13:34:12] remi dot lanvin at bsocom dot com
Description:
------------
Using PDO::FETCH_KEY_PAIR as an argument to
PDOStatement->setFetchMode() cause an error.
Note : PDO::FETCH_KEY_PAIR works well when used directly as an argument
to fetchAll() without setFetchMode().
Reproduce code:
---------------
$dbh = new PDO($dsn, $login, $password);
$sql = 'SELECT id, login FROM user u';
$results = $dbh->query($sql);
$results->setFetchMode(PDO::FETCH_KEY_PAIR);
print_r($results->fetchAll());
Expected result:
----------------
An associative array ('id' => 'login')
Actual result:
--------------
SQLSTATE[22003]: Numeric value out of range: Invalid fetch mode
specified
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42917&edit=1