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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 08:01:28 2024 UTC