php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #47749 PDO::FETCH_COLUMN only accepts a 0-indexed parameter
Submitted: 2009-03-22 19:45 UTC Modified: 2009-03-22 19:57 UTC
From: matteo at beccati dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: matteo at beccati dot com
New email:
PHP Version: OS:

 

 [2009-03-22 19:45 UTC] matteo at beccati dot com
Description:
------------
The documentation mentions that PDO::FETCH_COLUMN accepts either a 1-indexed integer or the column name as string. While fixing #44173 I've noticed that both hints are wrong. On PHP 5.3 any string is casted to int (therefore becoming 0) and the parameter is in fact supposed to be 0-indexed.

Note: the proposed fix for #44713 enforces the colno parameter to be integer.

A documentation patch will be available shortly.

Reproduce code:
---------------
var_dump($db->query("SELECT 1 as a, 2 as b", PDO::FETCH_COLUMN, 'b')->fetch());

Expected result:
----------------
string(1) "2"

Actual result:
--------------
string(1) "1"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-22 19:57 UTC] matteo at beccati dot com
I was checking the wrong manual page while reviewing #44173. Sorry for the noise.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 16 10:01:29 2025 UTC