Peter54 wrote On 06/10/2008 02:05 AM:
> First off I'm not just new to Cake I'm new to programing. I can get my
> head around relatively simple stuff and can generalize once I have a
> concept but even though I know this is either obvious, or been
> answered a thousand times I can't see it anywhere or figure out how it
> works.
>
> I have a two tables Recipes and Ingredients and a JoinTable
> Ingredients_Recipes that contains the foreign keys plus some other
> data.
>
> In my controller I have the following code:
>       $recipe = $this->Recipe->find(array('ShowDate'=>$today));
>               $this->set('todays_recipe', $recipe);
>
> Which in debug send all the relevant elements of the all tables to the
> view:
> $___dataForView       =       array(
>       "todays_recipe" => array(
>       "Recipe" => array(
>       "recipe_id" => "20",
>       "RecipeName" => "Banana Bread",
> ),
>       "Ingredient" => array(
>       array(
>       "ingredient_id" => "1",
>       "IngredientName" => "Eggs",
>       "IngredientsRecipe" => array(
>       "id" => "1",
>       "recipe_id" => "20",
>       "ingredient_id" => "1",
>       "Amount" => "2",
> )
>
> In my view code
> echo @"The dinner for $today is {$todays_recipe[Recipe]['RecipeName']}
> ';
>
> and I can generalize that to display anyting in the recipe array ie
> serves = $todays_recipe[Recipe]['Serves']";
>
> But when I try this with the Ingredients using - echo "this
> {$today_recipe[Ingredient]['IngredientName']}";
>
> I get undefined constants or undefined variables.
>
> I assume I have to declare the ingredients array in the controller or
> assign it to a variable but how? I don't know and  at the risk of
> appearing stupid or irritating I thought I'd ask.
>   
Hi,

Isn't it a quote problem ? U do $today_recipe[Ingredient] instead of 
$today_recipe['Ingredient'].
I hope it's because of it ;)

-- 
Simon COURTOIS
{EPITECH.} tek4 | (LINAGORA) Developer | [ADITAM] Project Manager
10, rue Brillat-Savarin 75013 Paris | 01 45 42 72 30 - 06 72 44 67 81
http://www.happynoff.fr


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to