On Mon, Jan 19, 2009 at 10:57 AM, [email protected]
<[email protected]> 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 [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
-~----------~----~----~----~------~----~------~--~---