On Thu, Sep 24, 2009 at 7:56 AM, invisibleman <[email protected]> wrote:
>
> Ah Thank you that makes alot of sense, for some reason i couldn't wrap
> my head around the best way to do this.
> I guess my next questions is how do i only delete from the join table
> in cakephp?
>
> Usually to delete from a table like the inbox or message i would use
> $this->NameofModel->delete(), do i need to setup a model file for the
> jointable too or something to delete specifically from that?
>
That's a good question. I'm actually not sure how best to unlink a
pair of records. You could always add an id column to the join table
and do $this->Message->InboxMessage->del($id). But you'd need to
determine the $id first.
The other way would be to use a plain SQL:
$this->Message->query('DELETE FROM inboxes_messages WHERE message_id =
'.$message_id);
There's a Model::_deleteLinks() method that does just this but it's
protected. Maybe someone else knows the proper Cake way to do this.
You might also find Mariano's SoftDeletableBehavior of use:
http://bakery.cakephp.org/articles/view/soft-delete-behavior
Just be aware that it's a few years old and may require some syntax
adjustments. I don't know if it's been kept up to date. Read the
comments in the article.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---