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

 ID:                 53651
 Updated by:         and...@php.net
 Reported by:        marc at phpmyadmin dot net
 Summary:            Under mysqlnd, mysqli_affected_rows() returns 0
-Status:             Assigned
+Status:             Feedback
 Type:               Bug
 Package:            MySQLi related
 Operating System:   Linux
 PHP Version:        5.3.4
 Assigned To:        mysql
 Block user comment: N
 Private report:     N

 New Comment:

Can you post output from the script with freshly created table and
freshly inserted row. Please, run the script twice. Thanks!


Previous Comments:
------------------------------------------------------------------------
[2011-01-05 12:00:16] marc at phpmyadmin dot net

Hi Andrey,

here is my configuration, maybe the presence of PDO has an impact?



./configure --with-apxs2=/usr/local/apache2/bin/apxs \

        --with-libdir=lib64 \

        --disable-debug \

        --enable-calendar \

        --with-gd=shared \

        --with-freetype-dir \

        --with-mysql=shared,mysqlnd \

        --with-mysqli=shared,mysqlnd \

        --with-regex=php \

        --with-png-dir=/usr/lib \

        --with-zlib=shared \

        --with-iconv=shared \

        --enable-ftp \

        --with-mcrypt=shared \

        --with-bz2=shared \

        --enable-zip \

        --with-jpeg-dir=/usr/lib \

        --enable-mbstring \

        --without-sqlite \

        --enable-dom \

        --enable-json \

        --enable-pdo=shared \

        --with-pdo-mysql=shared,mysqlnd \

        --without-pdo-sqlite \

        --with-pear \

        --enable-spl \

        --enable-bcmath \

        --with-curl=shared \

        --with-ldap=shared,/usr \

        --with-gettext=shared \

        --with-snmp=shared \

        --enable-sockets

------------------------------------------------------------------------
[2011-01-05 10:31:08] and...@php.net

I can't reproduce it. Maybe it's bogus due to something else. Here are
my results :



myslqnd + MySQL 5.5.8 (executed twice in a row)



and...@poohie:/work/vanilla/php/php-src/branches/PHP_5_3$ ./php b.php

Affected rows (UPDATE): 1

and...@poohie:/work/vanilla/php/php-src/branches/PHP_5_3$ ./php b.php

Affected rows (UPDATE): 0



myslqnd + MySQL 5.1-dev (executed twice in a row)

and...@poohie:/work/vanilla/php/php-src/branches/PHP_5_3$ ./php b.php

Affected rows (UPDATE): 1

and...@poohie:/work/vanilla/php/php-src/branches/PHP_5_3$ ./php b.php

Affected rows (UPDATE): 0



As you see, the second time the result is 0. Why? It is a feature or
gotcha of MySQL. If the row doesn't change affected_rows is 0. And the
row doesn't change from toto to toto there is no change, thus the row is
left intact.

------------------------------------------------------------------------
[2011-01-04 19:08:06] marc at phpmyadmin dot net

Description:
------------
In PHP 5.3.4 (also 5.3.3 and 5.3.2), connecting to MySQL 5.1.49 with
mysqli extension under mysqlnd, I always obtain 0 as the result of
mysqli_affected_rows() following an UPDATE that changed one row.



Works fine under PHP 5.2.14 + MySQL 5.1.49 client library.



Thanks,

Marc Delisle

Test script:
---------------
<?php

$link = mysqli_init();



mysqli_real_connect($link, 'localhost', 'user', 'password', 'db');



/*

 * CREATE TABLE mytable (id int not null, myname varchar(50 not null))
engine=MyISAM;

 * INSERT INTO mytable (id, myname) values(1, 'toto');

 */



mysqli_query($link, "update mytable set myname='Marc' where id=1");



printf("Affected rows (UPDATE): %d\n", mysqli_affected_rows($link));



mysqli_close($link);



?>

Expected result:
----------------
Affected rows (UPDATE): 1

Actual result:
--------------
Affected rows (UPDATE): 0


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=53651&edit=1

Reply via email to