|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-01-12 18:44 UTC] dharman@php.net
-Status: Open
+Status: Duplicate
[2021-01-12 18:44 UTC] dharman@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 19:00:02 2025 UTC |
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.