#51041 [Opn->Asn]: mysql_affected_rows() doesn't count rows affected through CASCADE foreign keys
| From: | abedford@php.net | Date: | Mon, 15 Feb 2010 10:08:11 +0000 |
| Subject: | #51041 [Opn->Asn]: mysql_affected_rows() doesn't count rows affected through CASCADE foreign keys | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-3889@lists.php.net to get a copy of this message | ||
ID: 51041
Updated by: abedford@php.net
Reported By: info at fedushin dot ru
-Status: Open
+Status: Assigned
Bug Type: Documentation problem
PHP Version: Irrelevant
Assigned To: abedford
Previous Comments:
------------------------------------------------------------------------
[2010-02-13 02:20:33] info at fedushin dot ru
Description:
------------
It would be useful to document the following:
mysql_affected_rows() DOES NOT count rows affected implicitly through
'ON DELETE CASCADE' and/or 'ON UPDATE CASCADE' foreign keys.
Reproduce code:
---------------
---
From manual page: function.mysql-affected-rows
---
CREATE TABLE
types (
type varchar(10) NOT NULL,
PRIMARY KEY (type)
) ENGINE=InnoDB;
CREATE TABLE symbols (
symbol char(1) NOT NULL,
type varchar(10) NOT NULL,
PRIMARY KEY (symbol),
KEY FK_symbol_type (type)
) ENGINE=InnoDB;
ALTER TABLE symbols
ADD CONSTRAINT FK_symbol_type FOREIGN KEY (type) REFERENCES
types (type) ON DELETE CASCADE ON UPDATE CASCADE;
INSERT INTO types VALUES ('Number'), ('Letter');
INSERT INTO symbols VALUES ('1', 'Number'), ('2',
'Number'), ('A',
'Letter'), ('B', 'Letter');
<?php
mysql_query('UPDATE types SET type = "Digit" WHERE type = "Number"');
echo mysql_affected_rows() . '<br>';
mysql_query('DELETE FROM types WHERE type = "Letter"');
echo mysql_affected_rows() . '<br>';
?>
Expected result:
----------------
Each query actually affects 3 rows (1 type + 2 symbols), but output
is:
1
1
Actual result:
--------------
That's OK, but needs to be documented.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=51041&edit=1