|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 08 07:00:02 2025 UTC |
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.foreach ($db->query($sql, PDO::FETCH_ASSOC) as $row) { } this isn't documented in the manual, but does work.