|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-02-24 14:13 UTC] svn@php.net
[2010-02-24 14:15 UTC] abedford@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 21:00:02 2026 UTC |
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.