Bug #70672 [NEW]: PDOStatement::fetchAll incomplete, incorrect
| From: | chealer at gmail dot com | Date: | Thu, 08 Oct 2015 15:42:43 +0000 |
| Subject: | Bug #70672 [NEW]: PDOStatement::fetchAll incomplete, incorrect | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-12814@lists.php.net to get a copy of this message | ||
From: chealer at gmail dot com
Operating system:
PHP version: Irrelevant
Package: Documentation problem
Bug Type: Bug
Bug description:PDOStatement::fetchAll incomplete, incorrect
Description:
------------
PDOStatement::fetchAll is relatively flexible, but poorly documented.
According to http://php.net/manual/en/pdostatement.fetchall.php
the
first parameter "Controls the contents of the returned array as
documented in PDOStatement::fetch()."
The documentation of the fetch_style argument of PDOStatement::fetch
reads:
Controls how the next row will be returned to the caller. This value
must be one of the PDO::FETCH_* constants, defaulting to value of
PDO::ATTR_DEFAULT_FETCH_MODE (which defaults to PDO::FETCH_BOTH).
PDO::FETCH_ASSOC: returns an array indexed by column name as
returned in your result set
PDO::FETCH_BOTH (default): returns an array indexed by both
column name and 0-indexed column number as returned in your result set
PDO::FETCH_BOUND: returns TRUE and assigns the values of the
columns in your result set to the PHP variables to which they were bound
with the PDOStatement::bindColumn() method
PDO::FETCH_CLASS: returns a new instance of the requested class,
mapping the columns of the result set to named properties in the class.
If fetch_style includes PDO::FETCH_CLASSTYPE (e.g. PDO::FETCH_CLASS |
PDO::FETCH_CLASSTYPE) then the name of the class is determined from a
value of the first column.
PDO::FETCH_INTO: updates an existing instance of the requested
class, mapping the columns of the result set to named properties in the
class
PDO::FETCH_LAZY: combines PDO::FETCH_BOTH and PDO::FETCH_OBJ,
creating the object variable names as they are accessed
PDO::FETCH_NAMED: returns an array with the same form as
PDO::FETCH_ASSOC, except that if there are multiple columns with the
same name, the value referred to by that key will be an array of all the
values in the row that had that column name
PDO::FETCH_NUM: returns an array indexed by column number as
returned in your result set, starting at column 0
PDO::FETCH_OBJ: returns an anonymous object with property names
that correspond to the column names returned in your result set
fetchAll returns a bidimensional array. While the values documented in
fetch's manual page allow controlling the contents of child arrays, they
do not mention how to control the parent array. fetchAll's manual hints
on how this can be done, but does not even mention some possible values
(for example PDO::FETCH_KEY_PAIR, described in
http://stackoverflow.com/questions/7451126/pdo-fetchall-group-key-value-pairs-into-assoc-array
and
http://blog.encodez.com/blog/using-pdofetchall-examples-with-codes-and-output-results
).
The Return Values section also needs to be fixed.
--
Edit bug report at https://bugs.php.net/bug.php?id=70672&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70672&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70672&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70672&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70672&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70672&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70672&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70672&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70672&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70672&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70672&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70672&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70672&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70672&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70672&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70672&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70672&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70672&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70672&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70672&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70672&r=mysqlcfg