php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16028 mysql_fetch_array() fails to index array correctly
Submitted: 2002-03-12 19:23 UTC Modified: 2002-03-12 19:38 UTC
From: mjm at porter dot appstate dot edu Assigned:
Status: Closed Package: MySQL related
PHP Version: 4.1.2 OS: GNU/Linux 2.4 (intel)
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mjm at porter dot appstate dot edu
New email:
PHP Version: OS:

 

 [2002-03-12 19:23 UTC] mjm at porter dot appstate dot edu
After some frustration, I performed the following SELECT query (column names have been changed):

$result = mysql_query("SELECT tbl1.colA, tbl2.colB, tbl2.colC FROM tbl1 LEFT JOIN tbl2 ON tbl1.colD = tbl2.colD WHERE tbl1.colE = "myvalue" ORDER BY tbl1.colF DESC, tbl2.colC ASC, tbl2.colD ASC", $handle);

I executed the following statements:

$row = mysql_fetch_array($result);
print_r(array_keys($row));

The output looked like this:

Array ( [0] => 0 [1] => 1 [2] => colB [3] => 2 [4] => colC )

This doesn't make any sense. When you SELECT from a LEFT JOIN it would make sense for you to be able to access the array like this (IMHO):

$row["tbl2.colB"], $row["tbl2.colC"], etc...


since two columns in the select could have the same name but different values.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-12 19:38 UTC] mjm at porter dot appstate dot edu
Oops, did query on bad table.
 [2002-03-12 19:38 UTC] mjm at porter dot appstate dot edu
Closing bug.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 10 19:01:28 2024 UTC