Thankyou both for that, I decided to override the delete() method on my object; it now checks if there are any children associated and if so, sets a user error flash and returns false. If not it calls parent::delete($conn). Works perfectly.
cheers Brett On Mar 30, 12:26 am, Campezzi <campe...@gmail.com> wrote: > I don't know if there's an easier way to do this, but I think I would > override the delete method on the parent model to do a custom > integrity check before actually trying to delete the record from the > database and returning false if it detects there will be constraint > problems. You can then add custom handling on your app in case the > delete method returns false, for example, redirecting the user > somewhere else, setting a flash message, etc. > > In case you're wondering, here's the signature for the function you'll > need to override (declared in the Doctrine_Record class, which is the > base class of your Doctrine-generated models): > > /** > * deletes this data access object and all the related composites > * this operation is isolated by a transaction > * > * this event can be listened by the onPreDelete and onDelete > listeners > * > * @return boolean true if successful > */ > public function delete(Doctrine_Connection $conn = null) > > Hope to have helped! > > Best Regards, > Thiago Campezzi > > On Mar 29, 9:01 am,bretth<brett...@gmail.com> wrote: > > > Hi, > > > I'm getting the error > > > SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or > > update a parent row: a foreign key constraint fails > > > when I delete a parent row from my admin generator. That's fine; it's > > doing what it should be doing; however I want to display a nicer error > > message for just this error along the lines of "You can't delete x > > because it has y linked to it". > > > Currently it just goes to the standard symfony error500 page; I don't > > want to just override the 500 error page with this message, because if > > the server ever gives error500s for other reasons it could potentially > > be confusing. > > > How can I display a custom error for "Integrity constraint violation" > > and leave my 500 page intact. > > > ...or.. is there another way to achieve what I'm trying to do? > > > Symfony 1.4, Doctrine, Mysql > > > thanks!! > > > Brett -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en To unsubscribe from this group, send email to symfony-users+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.