Deleting and habtm associations

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Deleting and habtm associations

goncalo.marrafa@gmail.com

Hi bakers.

I'm trying to delete a record from a model Foo that has a habtm association
with a model Bar, through a foo_bar table. The problem is that when i try
to delete the Foo record i get a constraint violation error because it is
still referenced from the record at foo_bar!

Shouldn't Cake delete the records of foo_bar that reference the record of
Foo i'm deleting? I'm setting delete's cascade parameter to true.

Am i missing something?

Thanks in advance.

--
Gonçalo Marrafa <[hidden email]>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Deleting and habtm associations

Microangelo-2

Hi Gonçalo,

Although I assume that your actual models aren't really called "Foo"
and "Bar" and you're just using the classic metasyntactic variables for
your example, I did want to point out that the Cake convention for join
tables is to go alphabetically, and so the join table should be named
"bar_foo" rather than "foo_bar".

As I said, this probably isn't your problem, but I thought I'd chuck it
in just in case you weren't aware of the convention.

Cheers,

    Chris


Gonçalo Marrafa wrote:

> Hi bakers.
>
> I'm trying to delete a record from a model Foo that has a habtm association
> with a model Bar, through a foo_bar table. The problem is that when i try
> to delete the Foo record i get a constraint violation error because it is
> still referenced from the record at foo_bar!
>
> Shouldn't Cake delete the records of foo_bar that reference the record of
> Foo i'm deleting? I'm setting delete's cascade parameter to true.
>
> Am i missing something?
>
> Thanks in advance.
>
> --
> Gonçalo Marrafa <[hidden email]>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Deleting and habtm associations

goncalo.marrafa@gmail.com

On Tue, 31 Oct 2006 02:04:12 -0800
"MicroAngelo" <[hidden email]> wrote:

>
> Hi Gonçalo,
>
> Although I assume that your actual models aren't really called "Foo"
> and "Bar" and you're just using the classic metasyntactic variables for
> your example, I did want to point out that the Cake convention for join
> tables is to go alphabetically, and so the join table should be named
> "bar_foo" rather than "foo_bar".

You're right about the names, of course. I didn't know about the
convention though. Thanks.

> As I said, this probably isn't your problem, but I thought I'd chuck it
> in just in case you weren't aware of the convention.
>

That's not my problem. At least i think it's not because everything else
works fine.

Thanks.

--
Gonçalo Marrafa <[hidden email]>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---