|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #56979 extra pdo::query parameters are not documented
Submitted: 2006-04-25 12:44 UTC Modified: 2006-04-29 22:39 UTC
From: phyre at rogers dot com Assigned: wez (profile)
Status: Closed Package: PDO (PECL)
PHP Version: 5_1 CVS-2006-04-25 OS: Linux
Private report: No CVE-ID: None
 [2006-04-25 12:44 UTC] phyre at rogers dot com
foreach ($dbc->query($sql) as $values)
 will make values have both the indexed and associative array entries.  A parameter should be available to return only one or the other, such as PDOStatement::setFetchMode constant.

Alternately, you should be able to set a default return type on a connection basis, such as _BOTH_ PDO::setFetchMode and PDOStatement::setFetchMode such as ADODB and PEAR allow.  This unfortunately applies some state, so it's probably best to include in the query command.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-25 12:58 UTC] phyre at rogers dot com
It should be noted (just discovered this), that this does work:

$stmt = $dbc->query($sql);
while ($replace = $stmt->fetch()) {
  // code

however this does not allow for 
  foreach ($dbc->query($sql) as $replace) {
to work properly, which is obviously a much faster solution to the issue.
 [2006-04-25 15:14 UTC]
foreach ($db->query($sql, PDO::FETCH_ASSOC) as $row) {

this isn't documented in the manual, but does work.
 [2006-04-29 22:39 UTC]
Documentation has been fixed in CVS.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 24 19:01:29 2024 UTC