Edit report at https://bugs.php.net/bug.php?id=65827&edit=1

 ID:                 65827
 User updated by:    ilantipov at gmail dot com
 Reported by:        ilantipov at gmail dot com
 Summary:            error passing mysqli_fetch_assoc results back
 Status:             Open
 Type:               Bug
 Package:            MySQLi related
 Operating System:   Ubuntu 12.04.1 LTS
 PHP Version:        5.4.20
 Block user comment: N
 Private report:     N

 New Comment:

php configure options  ./configure   --enable-fpm   --enable-libxml   
--with-mcrypt   --enable-mbstring   --with-gd   --with-mysql-sock   
--with-mysqli=mysqlnd   --with-pdo-mysql=mysqlnd   --with-mysql=mysqlnd   
--enable-sockets   --with-iconv   --with-gettext   --with-zlib   
--with-freetype-dir=/usr   --with-jpeg-dir=/usr   --prefix=/usr/local/php-fpm   
--with-config-file-path=/usr/local/php-fpm/etc   
--with-config-file-scan-dir=/usr/local/php-fpm/etc/conf.d   
--with-fpm-user=www-data   --with-fpm-group=www-data   --disable-simplexml   
--disable-xmlreader   --disable-xmlwriter   --disable-tokenizer   
--without-sqlite3   --without-pdo-sqlite   --with-curl


Previous Comments:
------------------------------------------------------------------------
[2013-10-03 15:10:02] ilantipov at gmail dot com

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 this bug report at https://bugs.php.net/bug.php?id=65827&edit=1

Reply via email to