#41325 [Opn]: mysqli_affected_rows() returns wrong value if warnings are raised
| From: | php-qa at sebastianmendel dot de | Date: | Tue, 08 May 2007 18:27:21 +0000 |
| Subject: | #41325 [Opn]: mysqli_affected_rows() returns wrong value if warnings are raised | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969376282@lists.php.net to get a copy of this message | ||
ID: 41325
User updated by: php-qa at sebastianmendel dot de
Reported By: php-qa at sebastianmendel dot de
Status: Open
Bug Type: Documentation problem
Operating System: Windows / Linux
PHP Version: 5.2.2
New Comment:
just to clarify: my test works as expected and not as i have written,
SORRY!
Previous Comments:
------------------------------------------------------------------------
[2007-05-08 17:17:46] php-qa at sebastianmendel dot de
ok, my fault, it is not a really a bug in mysqli_affected_rows() - it
is more a documentation bug
the mysql c api function mysql_affected_rows returns not only for teh
last INSERT, UPDATE, REPLACE or DELETE, but for SELECT too
"returns the number of rows changed (for) UPDATE), deleted (for DELETE,
or inserted (for INSERT. For SELECT statements, mysql_affected_rows()
works like mysql_num_rows()."
http://dev.mysql.com/doc/refman/5.1/en/mysql-affected-rows.html
and mysqli_affected_rows() does it the same way, of course, but the php
manual does read other
"Returns the number of rows affected by the last INSERT, UPDATE,
REPLACE or DELETE query."
http://php.net/mysqli_affected_rows
------------------------------------------------------------------------
[2007-05-08 15:28:06] tony2001@php.net
Cannot reproduce on Linux with both client & server of version 5.0.26.
------------------------------------------------------------------------
[2007-05-08 15:07:07] scottmac@php.net
I can't reproduce this with 5.0.27. I get the expected output of 1.
Do you have any other sort of special configuration or setting?
------------------------------------------------------------------------
[2007-05-08 14:50:46] php-qa at sebastianmendel dot de
Description:
------------
issuing an insert statement that raises warnings mysqli_affected_rows()
returns the warning count instead of inserted rows count
tested with MySQL server 5.0, 5.1 and 5.2 (6.0)
Reproduce code:
---------------
// open db connection/select db
//$mysqli = mysqli_...
// create table
$sql = 'CREATE TABLE
test (
id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
int int(11) NOT NULL,
int2 int(11) NOT NULL,
PRIMARY KEY (id)
)';
mysqli_query($mysqli, $sql);
// insert row
$sql = 'INSERT INTO test (int, int2) VALUES
('', '');'
mysqli_query($mysqli, $sql);
echo mysqli_affected_rows($mysqli);
Expected result:
----------------
1
Actual result:
--------------
2
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41325&edit=1