phpLens
 home  products examples manual  faq support forum  contact news  login store

Forums: phplens   adodb
Forums:   ADOdb Help & Dev:   Replies 
New ReplySearch
Topic: foreign key constraint errors in mysql being ignored.
author: Cal Evans   created: 13-03-2003 11:23:05 AM
I'm trying to update a row in an InnoDB table with a FK constraint on it. Using the replace function I see the UPDATE being issued. In this case, the update is failing because the FK constraint is failing.

With debug set to true I see the error:
1216: Cannot add a child row: a foreign key constraint fails

BUT , because of $this->poorAffectedRows is true, it immediately issues a Select count(*). This wipes out any errors that the update would have returned. Therefore when I check my error codes after the replace is done, I get 0 and the function returns as if the statement worked.

In my particular case, adding:
if ($this->ErrorNo()<>0) return 0;

just after the initial Execute (line 945 of adodb-connection.inc.php)

helps. However, I have not tested this with other database drivers.

Other suggestions would be appreciated.

=C=

* Cal Evans
* Stay Plugged Into Your Audience
* http://www.christianperformer.com
Topic: Re:foreign key constraint errors in mysql being ignored.
author: John Lim   created: 14-03-2003 00:26:21 AM
Thanks for the bug report. I have added the errorno check.
Page 1
New ReplySearch

View Source

email: contact#phplens.com (change # to @)     telephone (malaysia): 60-3-7947 2888     fax (malaysia): 60-3-7947 2800