Bug #77188 [NEW]: mysqli_affected_rows unexpectedly returning -1
| From: | rschuetz at hmcw dot de | Date: | Fri, 23 Nov 2018 08:50:42 +0000 |
| Subject: | Bug #77188 [NEW]: mysqli_affected_rows unexpectedly returning -1 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-218093@lists.php.net to get a copy of this message | ||
From: rschuetz at hmcw dot de
Operating system: Xubuntu 18.04
PHP version: 7.2.12
Package: MySQLi related
Bug Type: Bug
Bug description:mysqli_affected_rows unexpectedly returning -1
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 bug report at https://bugs.php.net/bug.php?id=77188&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77188&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77188&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77188&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77188&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77188&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77188&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77188&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77188&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77188&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77188&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77188&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77188&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77188&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77188&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77188&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77188&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77188&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77188&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77188&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77188&r=mysqlcfg