Re: easy way to find out if onetomany record is used (before deleting it)?

2009-04-14 Thread qwanta
Thanks, that's what I was looking for, I have not used behaviors yet. While researching beforeDelete I came across the hasAny() function which also helps. My current way of doing things also displays a list of all the records ("books") that belongTo the record that has been attempted to be delete

Re: easy way to find out if onetomany record is used (before deleting it)?

2009-04-14 Thread Richard
Depending on your database, you may be able to use constraints on the foreign keys of your database ("ON DELETE RESTRICT"), however that's a responsive check rather than pro-active. In your situation, you may find creating a behavior would be beneficial. The behavior would run the checks on the bef

easy way to find out if onetomany record is used (before deleting it)?

2009-04-14 Thread qwanta
In the case where If I have a one to many relationship like Authors- >Books and I would like to delete an author - but only if this author has no books - is there a buiilt-in way to check? I find that I run into this situation a lot (every time a table has a foreign key), and at the moment manual