Ok I get it. Thanks man I really appreciate your time.

Steve
 

-----Original Message-----
From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf
Of brian
Sent: Monday, January 19, 2009 1:13 PM
To: cake-php@googlegroups.com
Subject: Re: Relationships - HABTM


Both Recipe and Ingredient should be HABTM with each other. You can have
many recipes which share ingredients. The join table for both would be:

ingredients_recipes
ingredient_id,
recipe_id

You could add an id primary key in there, also, as it might come in handy.
It's not required, though.

As for IngredientList, I'm not sure I've never thought much about doing this
with Cake. I guess you could put the amount info, etc. in the
ingredients_recipes join table but I'm not sure that'd be the best way.

On Mon, Jan 19, 2009 at 12:50 PM, Steven Wright <rhythmicde...@gmail.com>
wrote:
>
> Hi Brian thanks for writing back.
>
> The ingredient_lists table is where the ingredient, amount and 
> ingredient level instructions are stored. I suppose it's really a join 
> table for recipes, ingredients and measurement_types. So from your 
> reply I should actually rename this to ingredients_recipes.
>
> And you are saying that the Ingredient model gets the HABTM instead of 
> Recipe. Is that correct?
>
>
>
>
> -----Original Message-----
> From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On 
> Behalf Of brian
> Sent: Monday, January 19, 2009 12:26 PM
> To: cake-php@googlegroups.com
> Subject: Re: Relationships - HABTM
>
>
> On Mon, Jan 19, 2009 at 10:57 AM, rhythmicde...@gmail.com 
> <rhythmicde...@gmail.com> wrote:
>>
>> I have been making some pretty good headway on defining the 
>> relationships for my models. However I am not getting some data that 
>> I expect to get. This may be due to my relationship definitions or a 
>> misunderstanding of what CakePHP will do for me. I am hoping one you 
>> can point me in the right direction.
>>
>> So am I missing something here? Wrong relationship definition? Wrong 
>> expectation?
>>
>> Thanks in advance.
>> Steve
>>
>>
>> I have the following models and relationship definitions:
>>
>> Recipe
>> var $hasAndBelongsToMany = array(
>>        'Ingredient' =>
>>            array(
>>                'className'              => 'Ingredient',
>>                'joinTable'              => 'ingredient_lists',
>>                'foreignKey'             => 'recipe_id',
>>                'associationForeignKey'  => 'ingredient_id',
>>                'unique'                 => true
>>                ),
>>           'MeasurementType' =>
>>            array(
>>                'className'              => 'MeasurementType',
>>                'joinTable'              => 'ingredient_lists',
>>                'foreignKey'             => 'recipe_id',
>>                'associationForeignKey'  => 'measurement_type_id',
>>                'unique'                 => true
>>                )
>>    );
>>
>>
>> IngredientList
>> var $belongsTo = array('Recipe', 'MeasurementType');
>>
>>
>> Ingredient
>> var $belongsTo = 'IngredientType';
>>
>
> I don't understand what you're doing with the ingredient_lists table.
> But your ingredient model, at least, should HABTM Recipe.
> Ingredient
> var $hasAndBelongsToMany = array('Recipe');
>
> And the join table should be ingredients_recipes.
>
>
>
> >
>



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to