There are several options that you can use as the solution to your issue: 1) Add constraints in your database, so that parent records can't be deleted while child records exists. This probably means that you should catch the database errors in the model (I assume) and then inform the user.
2) Add usage of counterCache to keep track of the number of children. See the CakePHP book at: - http://book.cakephp.org/view/816/counterCache-Cache-your-count 3) Roll your own find to count the child records (worst solution) but may be fine if deletions seldom take place. Enjoy, John On Apr 16, 10:05 pm, mivogt-LU <[email protected]> wrote: > hi there, cake stats to be a nice toy & tool so far :) ... > > I am on the next step of developing my littl app and would like to get > some hints how to do best this: > > I have 3 models linked with each other > mod1, mod2, mod3 > mod 1 hasOne mod2 > mod2 hasMany mod3 > > So deleting some mod1 data with having a related in mod2 would be no > good idea. > How can I avoid deleting a model entry if a related entry in other > models exist? > > Thanks in advance > > Michael > > cake 1.3 RCx [snip] Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
