From: yvan dot garnier at laposte dot net
Operating system: Linux Mandrake 9
PHP version: 4.2.3
PHP Bug Type: MySQL related
Bug description: mysql_fetch_array / assoc return row twice
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 bug report at http://bugs.php.net/?id=22498&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=22498&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=22498&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=22498&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=22498&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=22498&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=22498&r=support
Expected behavior: http://bugs.php.net/fix.php?id=22498&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=22498&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=22498&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=22498&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22498&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=22498&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=22498&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=22498&r=gnused