That will only work if your database engine supports foreign key constraints, such as MySQL InnoDB. The default MySQL MyISAM engine does not support any type of referential integrity; you can set the FOREIGN KEY/REFERENCES attributes, but they will be ignored.
Other database implementations may also be lacking foreign key constraints, but my experience is localized to PostgreSQL and MySQL. It's probably worth opening up a ticket concerning your issue, since one would expect that the default behaviour for 'dependent' would allow the deletion of the associated entry in the join table, effectively unlinking the two model records in question. I agree with Dave, however, in that in most cases you would not want to delete the associated records in a HABTM relationship (as opposed to the entry in the join table) for obvious reasons. -Joel. On Aug 20, 5:12 pm, Marcello <[EMAIL PROTECTED]> wrote: > im a little new to referential integrity in the database directly, > could you enligthen me? > > i got 5 tables > > Clients AddressClient Addresses > Sellers AddressSeller > > what i need is, when i delete a client or a seller, it should also > delete his addresses, BUT when i delete a address the client or seller > must remain untouched > > On 20 ago, 12:45, nachopitt <[EMAIL PROTECTED]> wrote: > > > Why don't you just do it the way its suppossed to be? By adding > > referential integrity to the database. For example: > > > CREATE TABLE / ALTER TABLE ... > > ... > > FOREIGN KEY (foreignTableName_id) REFERENCES foreignTableName ON > > DELETE CASCADE; > > > On Aug 20, 9:21 am, Marcello <[EMAIL PROTECTED]> wrote: > > > > the main reason for using habtm is because address table is shared > > > among the whole system > > > > clients use them, sellers, and so on > > > and a client can have ANY NUMBER of addresses > > > the same for seller > > > so i cant put a foreign key in any of the two tables > > > > thats why i must use HABTM > > > > On 20 ago, 10:50, Dave J <[EMAIL PROTECTED]> wrote: > > > > > Not sure if I made sense in my previous post, but basically this is a > > > > case in which, if you're in a situation where you need todelete > > > > dependent records in an HABTM relationship..... you might need to > > > > think if the relationship should be an HABTM one at all... or if a > > > > simpler hasMany would do the job just as well. > > > > > On Aug 20, 2:44 pm, Dave J <[EMAIL PROTECTED]> wrote: > > > > > > I dont think it works for HABTM relations.... also for the reason > > > > > that it might be unsafe to do so. By deleting all related records, you > > > > > might also be deleting records which are referenced to by other > > > > > entries in the join table. > > > > > > On Aug 20, 4:03 am, Marcello <[EMAIL PROTECTED]> wrote: > > > > > > > it does not work (gives no error, but does not remove the dependent > > > > > > side) > > > > > > > On 19 ago, 22:26, Marcello <[EMAIL PROTECTED]> wrote: > > > > > > > > dependent is exactly what i was looking for > > > > > > > > thanks! > > > > > > > > On 19 ago, 22:11, Joel Perras <[EMAIL PROTECTED]> wrote: > > > > > > > > > Take a look > > > > > > > > athttp://book.cakephp.org/view/66/models#deleting-data-516 > > > > > > > > . The 'dependent' parameter can also be set in the model > > > > > > > > association > > > > > > > > definition. > > > > > > > > > Hope that's what you were looking for. > > > > > > > > -J. > > > > > > > > > On Aug 19, 8:52 pm, Marcello <[EMAIL PROTECTED]> wrote: > > > > > > > > > > i got 2 tables linked by a HABTM relationship > > > > > > > > > > when ideletetable record 1 i want todeletethe relationship > > > > > > > > > with > > > > > > > > > table and the table 2 record as well > > > > > > > > > but when ideletefrom table 2 i want to keep table 1 record > > > > > > > > > > is there any feature in cakephp forcascadingin habtm? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
