php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8656 mysql_fetch_object duplicate return values
Submitted: 2001-01-11 11:38 UTC Modified: 2001-01-14 17:10 UTC
From: sigma at headquarters dot ca Assigned:
Status: Closed Package: MySQL related
PHP Version: 4.0.3pl1 OS: Linux RedHat 6.2 kernal 2.2.18
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sigma at headquarters dot ca
New email:
PHP Version: OS:

 

 [2001-01-11 11:38 UTC] sigma at headquarters dot ca
configure line:
quick install

script:
for ($i = 0; ($row = mysql_fetch_object($results)) != false;
$i++) {
	foreach ($row as $key => $value) {
		$orders[$i][$key] = $value;
	}
}
foreach($orders as $value) {
	foreach($value as $key => $here) {
		echo "key = $key, value = ".$value[$key]."\n";
	}
}

will produce
key = 0, value = first value
key = database_column, value = first value
key = 1, value = second value
key = database_column, value = second value
...

description:
This is basically reproducing the column in a numbered and
named row in the returned array.

This is against the documentation that states that we can
only access the values by the column name because numbers
are illegal property names.  It seems to me that the default
is MYSQL_BOTH but that by the documentation that isn't true.
 By the documentation it seems to me that the default is
MYSQL_ASSOC.

I posted a note to the page to always use MYSQL_ASSOC/NUM as
the result_type.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-01-14 17:10 UTC] sniper@php.net
Fixed in CVS.

--Jani
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 07:01:30 2024 UTC