From:             ilantipov at gmail dot com
Operating system: Ubuntu 12.04.1 LTS
PHP version:      5.4.20
Package:          MySQLi related
Bug Type:         Bug
Bug description:error passing mysqli_fetch_assoc results back

Description:
------------
mysqli_fetch_assoc($query_id) gives results, but 
$row2 = $db->sql_fetchrow($result));
print_r($row2);
does not

Test script:
---------------
I am using phpbb3 while running a query 
when I use this code 
$query = "SELECT t.forum_id, count(topic_id) AS count_sticky FROM
phpbb_topics as t, phpbb_prices_forums as f WHERE t.forum_id=f.forum_id
AND f.forum_id IN (509, 545, 25, 45, 543, 20, 35, 487, 223, 288, 224,
256) AND topic_type=1 and topic_sticky_flag > 0 GROUP BY t.forum_id
HAVING count_sticky <5";
if ($result = mysqli_query($link, $query)) {
  
    while ($row = mysqli_fetch_row($result)) {
        printf ("%s (%s)\n", $row[0], $row[1]);
    }
}

I get 
256 (4)
543 (1)

Which is ok. But when I'm using this code 
$result  = $db->sql_query($sql);
while($row2 = $db->sql_fetchrow($result));
{
    print($row2);
}

I get nothing. And gettype($row2) gives NULL

$db->sql_fetchrow in minimal configuration to reproduce a bug is:

function sql_fetchrow($query_id = false)
{

                return mysqli_fetch_assoc($query_id);
}

If I rewrite my code to 
$result  = $db->sql_query($sql);

print_r($db->sql_fetchrow($result));
print_r($db->sql_fetchrow($result));

I get
Array
(
    [forum_id] => 256
    [count_sticky] => 4
)
Array
(
    [forum_id] => 543
    [count_sticky] => 1
)

The other variant of code:
$result  = $db->sql_query($sql);

$row2 = $db->sql_fetchrow($result);
print_r($row2);
$row2 = $db->sql_fetchrow($result);
print_r($row2);

Gives good results as well. It works as acpected.

So the bug occures only in this case - when passing back results to
'while' loop as a result of other function. All other queries work
perfect on a production server. And I have the same issues on 2 servers
with PHP 5.4.17 and PHP 5.4.20 running.

Any other info can be sent if needed.


-- 
Edit bug report at https://bugs.php.net/bug.php?id=65827&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=65827&r=trysnapshot54
Try a snapshot (PHP 5.5):   
https://bugs.php.net/fix.php?id=65827&r=trysnapshot55
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=65827&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=65827&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=65827&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=65827&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=65827&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=65827&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=65827&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=65827&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=65827&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=65827&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=65827&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65827&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=65827&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=65827&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=65827&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65827&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=65827&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=65827&r=mysqlcfg

Reply via email to