#22498 [Bgs->Csd]: mysql_fetch_array / assoc return row twice
| From: | yvan dot garnier at laposte dot net | Date: | Tue, 04 Mar 2003 16:33:29 +0000 |
| Subject: | #22498 [Bgs->Csd]: mysql_fetch_array / assoc return row twice | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-34784@lists.php.net to get a copy of this message | ||
ID: 22498
User updated by: yvan dot garnier at laposte dot net
Reported By: yvan dot garnier at laposte dot net
-Status: Bogus
+Status: Closed
Bug Type: MySQL related
Operating System: Linux Mandrake 9
PHP Version: 4.2.3
New Comment:
Upgraded to 4.3.1
Problem fixed
Previous Comments:
------------------------------------------------------------------------
[2003-03-02 12:10:34] sniper@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP --
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php
If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.
4.3.1 is already out..
------------------------------------------------------------------------
[2003-03-01 16:38:46] yvan dot garnier at laposte dot net
Query with grouping options return row twice when trying
to have associative array as result :
$sql ="SELECT MAX(date_send) AS max_date,idmess FROM sending WHERE
user='me' GROUP BY idmess HAVING max_date<(NOW()-INTERVAL 1 MONTH)"
$res_sql=mysql_query($id_cnx,$sql)
Using any of :
$res = mysql_fetch_array($res_sql,MYSQL_ASSOC)
or $res = mysql_fetch_assoc($res_sql)
foreach ( $res as $field=>$value ) {
echo "field name ".$field." value = ".$value }
This return each row twice with the same values while
MAX function with GROUP BY would return only one
This query works fine in MySQL console
This is also running correctly using mysql_fetch_objet
while ( $res = mysql_fetch_object($res_sql)) {
echo "field name ".$res->idmess." value ".$res->max_date
return only one row per value
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=22498&edit=1