php.net |  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: phyre at rogers dot com
New email:
PHP Version: OS:

 

 [2006-04-25 12:44 UTC] phyre at rogers dot com
Description:
------------
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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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);
$stmt->setFetchMode(PDO::FETCH_ASSOC);
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] wez@php.net
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] wez@php.net
Documentation has been fixed in CVS.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 26 09:01:32 2024 UTC