php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30349 MySQL returning false result array when using large query
Submitted: 2004-10-07 05:17 UTC Modified: 2004-10-07 07:09 UTC
From: cgroen at xs4all dot nl Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 5.0.2 OS: Linux (Debian Sarge)
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cgroen at xs4all dot nl
New email:
PHP Version: OS:

 

 [2004-10-07 05:17 UTC] cgroen at xs4all dot nl
Description:
------------
Mysql version: 4.1.4-gamma-standard-log
PHP version: 5.0.2
PHP config: /configure --with-apxs=/usr/bin/apxs --with-mysqli=/usr/bin/mysql_config --with-oci8=/usr/local/oracle/product/8.1.7 --with-config-file-path=/etc

I have built a PHP program that automatically builds very complex queries and parses them.. Up until version 5.0.1 of PHP, everything worked fine but since I installed 5.0.2 everything falls apart.. 
When running a very big/complex query, somehow the result array gets mangled.. It contains index numbers that where never in the query to begin with (like in the query below, it returns indexes ranging from 1 till 565) and index numbers that should have values don't..
This is the case with both MySQL and MySQLi.. Like I said, everything worked fine with PHP 5.0.1, it's just 5.0.2 that has this problem..

When running the query in MySQL client everything goes well and the right values are assigned to the right columns..

Hope I made the problem clear..
Regards,
Carlos


Reproduce code:
---------------
http://www.gris.nl/code.html

Expected result:
----------------
An associative array with the column numbers specified in the query as index keys for the appropriate values..

Actual result:
--------------
An array with non existing keys (in the query) and with keys that point to the wrong column's result..

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-07 05:40 UTC] cgroen at xs4all dot nl
Guess it's not a bug.. Started thinking about it and looked up the mysql_fetch_array description.. 
The lower index numbers are the indexes the function adds (mysql_fetch_array returns an array with both associative and numbered keys)..

What still remains is the question why PHP versions prior to 5.0.2 didn't have a problem with this ? Somehow 5.0.2 implements the mysql_fetch_array function different from it's predecessors..
 [2004-10-07 07:09 UTC] georg@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Don't use numeric column aliases when you use mysql_fetch_assoc with MYSQL_BOTH. These aliases will override numeric indexes (or vice versa) in your array.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 06:01:34 2024 UTC