|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42917 PDO::FETCH_KEY_PAIR doesn't work with setFetchMode
Submitted: 2007-10-10 13:34 UTC Modified: 2007-10-11 20:58 UTC
From: remi dot lanvin at bsocom dot com Assigned: iliaa
Status: Closed Package: PDO related
PHP Version: 5.2.4 OS: Linux
Private report: No CVE-ID:
 [2007-10-10 13:34 UTC] remi dot lanvin at bsocom dot com
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);

Expected result:
An associative array ('id' => 'login')

Actual result:
SQLSTATE[22003]: Numeric value out of range: Invalid fetch mode specified


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-11 20:58 UTC]
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
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Wed Nov 25 23:01:33 2015 UTC