Nice, we got it! Just using deleteAll before the normal Listing->del
...
/*
---------------------------------------------------------------------- */
$conditionsArticle = array('Article.listing_id'=> (int) $id);
$conditionsImage = array('Image.listing_id'=> (int) $id);
/*
---------------------------------------------------------------------- */
$this->Listing->Article->deleteAll($conditionsArticle, true, true);
$this->Listing->Image->deleteAll($conditionsImage, true, true);
$this->Listing->Catalog->deleteAll($conditionsCatalog, true, true);
/*
---------------------------------------------------------------------- */
if ($this->Listing->del((int) $id, true)) {
...
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
-~----------~----~----~----~------~----~------~--~---