php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55053 PDO::FECTH_KEY_PAIR doesn't work as expected
Submitted: 2011-06-14 15:43 UTC Modified: 2011-12-05 22:33 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:1 of 2 (50.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: dmitry dot chirkin at gmail dot com Assigned: frozenfire (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.3.6 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
36 - 19 = ?
Subscribe to this entry?

 
 [2011-06-14 15:43 UTC] dmitry dot chirkin at gmail dot com
Description:
------------
If you try to use $stmt->fetchAll(PDO::FETCH_KEY_PAIR) on result set with more 
than two columns, error occurs: 

Warning: PDOStatement::fetchAll() [pdostatement.fetchall]: SQLSTATE[HY000]: 
General error: PDO::FETCH_KEY_PAIR fetch mode requires the result set to contain 
extactly 2 columns.

But documentation says: 

PDO::FETCH_KEY_PAIR (integer)
Fetch into an array where the 1st column is a key and all subsequent columns are 
values

There are should be no limit for columns.

Thanks

Expected result:
----------------
No error

Actual result:
--------------
Warning: PDOStatement::fetchAll() [pdostatement.fetchall]: SQLSTATE[HY000]: 
General error: PDO::FETCH_KEY_PAIR fetch mode requires the result set to contain 
extactly 2 columns.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-01 19:33 UTC] felipe@php.net
-Package: *Database Functions +Package: Documentation problem
 [2011-12-05 22:31 UTC] frozenfire@php.net
Automatic comment from SVN on behalf of frozenfire
Revision: http://svn.php.net/viewvc/?view=revision&revision=320468
Log: Changed the description of PDO::FETCH_KEY_VALUE to match actual behaviour (requiring the result set to have exactly two columns). Closes bug #55053.
--
Provided by anonymous #11351 ()
 [2011-12-05 22:33 UTC] frozenfire@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2011-12-05 22:33 UTC] frozenfire@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: frozenfire
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 16 17:01:37 2024 UTC