#51041 [NEW]: mysql_affected_rows() doesn't count rows affected through CASCADE foreign keys
| From: | info at fedushin dot ru | Date: | Sat, 13 Feb 2010 02:20:33 +0000 |
| Subject: | #51041 [NEW]: mysql_affected_rows() doesn't count rows affected through CASCADE foreign keys | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-3882@lists.php.net to get a copy of this message | ||
From: info at fedushin dot ru
Operating system:
PHP version: Irrelevant
PHP Bug Type: Documentation problem
Bug description: mysql_affected_rows() doesn't count rows affected through CASCADE foreign
keys
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 bug report at http://bugs.php.net/?id=51041&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51041&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51041&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51041&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=51041&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51041&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=51041&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=51041&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=51041&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=51041&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=51041&r=support
Expected behavior: http://bugs.php.net/fix.php?id=51041&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=51041&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=51041&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=51041&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51041&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=51041&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=51041&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=51041&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=51041&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=51041&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=51041&r=mysqlcfg