I work with mysql and codeigniter using ORM redbean. After implementing the foreign key for many, many associations, I received the following error at startup:
drop TABLE IF EXISTS `temp`
Integrity constraint violation: 1217 Cannot delete or update a parent row: a foreign key constraint fails thrown
Then I introduced SHOW ENGINE INNODB STATUS to phpmyadmin. The output includes:
LATEST FOREIGN KEY ERROR------------------------: Cannot drop table `db1`.`temp`because it is referenced by `db1`.`temp_workers`.
In other words, another table refers to FK. For testing purposes, I believe that it is best to drop all related tables and recreate them using the controller that I am testing. Is this the best way to go? I tried:
drop TABLE IF EXISTS `temp` `temp_workers`
but I still get the above error and the drop command does not work. Also:
truncate TABLE `temp`, `temp_workers`
gives:
You have an error in your SQL syntax
source
share