Ok, I'm probably being really dumb here, but I can't figure out how to 
delete an associated record when the association is HABTM.

I have the following:

*Invoice:*
    
    public $hasAndBelongsToMany = array(
        'Flag' => array(
            'counterCache' => true,
        )
    );

I can add flags to invoices no problem (just by creating 
$invoice['Flag'][...] and then saving the invoice), but I can't figure out 
how to delete them!

I've tried:
  $this->FlagInvoice->deleteAll( array( 'invoice_id' => $invoice_id, 
'flag_id' => $flag_id ) );
and
  $this->FlagInvoice->deleteAll();

but I get "Call to a member function deleteAll() on a non-object" 
(presumably for the 'FlagInvoice').

If I add 'FlagInvoice' to the $uses variable at the top of the controller, 
I get the error that the table doesn't exist in the database.

I know I'm missing something really obvious here (I'm pretty certain I've 
even done this before!), but I've looked online, and I can't find an 
answer.  Can anyone help? Thanks!

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to