#47749 [NEW]: PDO::FETCH_COLUMN only accepts a 0-indexed parameter

From: Date: Sun, 22 Mar 2009 19:45:53 +0000
Subject: #47749 [NEW]: PDO::FETCH_COLUMN only accepts a 0-indexed parameter
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-2024@lists.php.net to get a copy of this message
From: matteo at beccati dot com Operating system: * PHP version: Irrelevant PHP Bug Type: Documentation problem Bug description: PDO::FETCH_COLUMN only accepts a 0-indexed parameter 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" -- Edit bug report at http://bugs.php.net/?id=47749&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47749&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47749&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47749&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=47749&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47749&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=47749&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=47749&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=47749&r=needscript Try newer version: http://bugs.php.net/fix.php?id=47749&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=47749&r=support Expected behavior: http://bugs.php.net/fix.php?id=47749&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=47749&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=47749&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=47749&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47749&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=47749&r=dst IIS Stability: http://bugs.php.net/fix.php?id=47749&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=47749&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=47749&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=47749&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=47749&r=mysqlcfg

« previous php.doc.bugs (#2024) next »