ID: 38475 User updated by: mirya at matrix dot ua Reported By: mirya at matrix dot ua Status: Bogus Bug Type: MySQL related Operating System: FreeBSD6.1 PHP Version: 5.1.4 New Comment:
I recently found it being mentioned in mysql C API docs (for mysql_fetch_row()), IMHO there should be a note in PHP docs too. 2 [EMAIL PROTECTED]: ensure you have mysql5 and no test.a, test.b tables ;) Previous Comments: ------------------------------------------------------------------------ [2006-08-17 05:46:39] [EMAIL PROTECTED] see http://bugs.mysql.com/bug.php?id=706 ------------------------------------------------------------------------ [2006-08-16 23:20:43] [EMAIL PROTECTED] Can't replicate. Please provide reproduce code that really works. ------------------------------------------------------------------------ [2006-08-16 18:03:49] mirya at matrix dot ua Description: ------------ Extract from mysql_error() php doc page: "Note that this function only returns the error text from the most recently executed MySQL function (not including mysql_error() and mysql_errno())..." I noticed that a error is not reset for mysql_fetch_*() call (server/client 5.0.22), mean if you perform mysql_query() for some data manipulation statement producing a error, then call mysql_fetch_*(), mysql_error() will return mysql_query() error message. So the docs page is inconsistent with current mysql lib behaviour Reproduce code: --------------- mysql_connect('localhost', 'mirya', 'my-passwd'); mysql_select_db('test'); mysql_query('CREATE TABLE a (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE = InnoDB'); mysql_query('CREATE TABLE b (b INT AUTO_INCREMENT PRIMARY KEY, a INT NOT NULL, FOREIGN KEY (a) REFERENCES a(a) ON DELETE REST mysql_query('INSERT a VALUES (1), (2), (3)'); $rs = mysql_query('SELECT a FROM a'); while ($row = mysql_fetch_assoc($rs)) { if (mysql_error()) die('Shouldn\'t happen: '.mysql_error()); mysql_query('INSERT b (a) VALUES (4)'); if (mysql_error()) echo "Foreign key constraint fails\n"; } echo "Finished w/o errors\n"; Expected result: ---------------- Foreign key constraint fails Finished w/o errors Actual result: -------------- Foreign key constraint fails Shouldn't happen: Cannot add or update a child row: a foreign key constraint fails (`test/b`, CONSTRAINT `b_ibfk_1` FOREIGN KEY (`a`) REFERENCES `a` (`a`)) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38475&edit=1