Welcome Guest, Not a member yet? Register   Sign In
How to handle MySQL CONSTRAINT / error number
#1

[eluser]Unknown[/eluser]
Hello CodeIgniter community,

I have an problem handling MySQL CONSTRAINT error.

For obvious reason, I can not delete record in MySQL table because another records in other table reference it.

Quote:A Database Error Occurred
Error Number: 1451

Cannot delete or update a parent row: a foreign key constraint fails (`treg`.`participant`, CONSTRAINT `fk_participant_seminar` FOREIGN KEY (`seminar_seminar_id`) REFERENCES `seminar` (`seminar_id`) ON DELETE NO ACTION ON UPDATE NO ACTION)

DELETE FROM `seminar` WHERE `seminar_id` = '31'

I need to know when this error is occurred to display appropriate error text to user.
Also I would like to have MySQL error number from last query.

How to handle this issue?


Messages In This Thread
How to handle MySQL CONSTRAINT / error number - by El Forum - 12-22-2010, 04:08 PM
How to handle MySQL CONSTRAINT / error number - by El Forum - 12-22-2010, 04:45 PM
How to handle MySQL CONSTRAINT / error number - by El Forum - 12-22-2010, 06:02 PM
How to handle MySQL CONSTRAINT / error number - by El Forum - 12-24-2010, 04:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB