Bug #77188 [Opn->Dup]: mysqli_affected_rows unexpectedly returning -1
| From: | dharman@php.net | Date: | Tue, 12 Jan 2021 18:44:15 +0000 |
| Subject: | Bug #77188 [Opn->Dup]: mysqli_affected_rows unexpectedly returning -1 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-231517@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77188&edit=1
ID: 77188
Updated by: dharman@php.net
Reported by: rschuetz at hmcw dot de
Summary: mysqli_affected_rows unexpectedly returning -1
-Status: Open
+Status: Duplicate
Type: Bug
Package: MySQLi related
Operating System: Xubuntu 18.04
PHP Version: 7.2.12
Block user comment: N
Private report: N
New Comment:
Duplicate of Bug #67348 Reading $dbc->stat modifies $dbc->affected_rows
Previous Comments:
------------------------------------------------------------------------
[2018-11-23 08:50:42] rschuetz at hmcw dot de
Description:
------------
I insert or update a row of a mysql table via mysqli_query. Then I try to get the number of affected
rows via mysqli_affected_rows. It returns 1. Everything works fine so far. Then I dump the mysqli
object via var_dump or print_r between the mysqli_query and mysqli_affected_rows calls.
Test script:
---------------
$link = mysqli_connect($my_host, $my_username, $my_password, $my_dbname);
if ($link)
{
mysqli_query($link, "create table
test (id int not null
auto_increment, name varchar(100) not null, primary key (id)) engine =
MyISAM charset = utf8mb4 collate utf8mb4_general_ci");
mysqli_query($link, "insert into test set name = 'Al
Bundy'");
var_dump($link);
echo 'affected rows = ' . mysqli_affected_rows($link) . "\n";
echo 'sqlstate error = ' . mysqli_sqlstate($link) . "\n";
}
Expected result:
----------------
I expected mysqli_affected_rows to return 1 because a dump of the mysqli object shouldn't
change anything about its internal state.
Actual result:
--------------
But mysqli_affected_rows unexpectedly returns -1. mysqli_sqlstate doesn't show any error,
returning '00000'.
I didn't experience this behavior if I use prepared statements and mysqli_stmt_affected_rows.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77188&edit=1