Thak you.
These are my model definitions: User hasMany Listing Listing hasMany Article Listing hasMany Image Article hasAndBelongsToMany Tag Image hasAndBelongsToMany Tag When i delete an article their tags are deleted ok. When i delete an image their tags are deleted ok. When i delete a Listing their associated images and articles are deleted ok, but the tags associated to the images or aticles deleted. We are using a custom behavior to add, update or delete tags for each image or article created, these are are their tables: CREATE TABLE IF NOT EXISTS `tags` ( `id` int(11) unsigned NOT NULL auto_increment, `name` varchar(30) character set utf8 NOT NULL, `model` varchar(50) character set utf8 NOT NULL, `ocurrances` int(11) unsigned NOT NULL, `created` datetime default NULL, `modified` datetime default NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM; CREATE TABLE IF NOT EXISTS `articles_tags` ( `id` int(11) unsigned NOT NULL auto_increment, `article_id` int(11) unsigned default NULL, `tag_id` int(11) unsigned default NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM; CREATE TABLE IF NOT EXISTS `images_tags` ( `id` int(11) unsigned NOT NULL auto_increment, `image_id` int(11) unsigned default NULL, `tag_id` int(11) unsigned default NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM; Like i said before, when i delete an artice or an image, the tags occurrances are updated and the tags are deleted. But not when i delete a Listing or User. There is way to force HABTM to be depandant with a custom action or any other solution? Thanks in advance. delocalizer wrote: > Hi Josoroma; > This nice post: (http://groups.google.com/group/cake-php/msg/ > c10840be78a34df0) although it is about finderQuery, will probably help > you a lot. I have to ask though - you sure you want to delete the Tags > themeselves and not just the ArticlesTags associations? What happens > if a Tag is shared between an article being deleted and one that > isn't? Or now that I think about it what you probably want is to > delete Tags that no longer belong to any Articles - in which case you > could also put some logic in your Article model afterDelete that calls > delete on unassociated Tags. Just a thought. > > On Aug 13, 3:34 am, Josoroma <[email protected]> wrote: > >> Im using the following structure: >> >> User hasMany Listing >> Listing hasMany Contacts >> Listings hasAndBelongsToMany Articles >> Articles hasMany Tags >> >> When i delete a User or a Listing all their associated Listings and >> Articles are successfully deleted. But not their Tags. Listings and >> Articles are deleted because we are using 'dependent'=> true in the >> hasMany Model Structure. But how can i delete the Tags of the Articles >> associated? do i have to use deleteQuery to achieve >> that?http://book.cakephp.org/view/83/hasAndBelongsToMany-HABTM >> >> I was searching in Google and there is not tutorial or post related to >> deleteQuery in HABTM associations. >> >> An example will help us a lot. >> >> Thanks in advance. >> > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
