On Apr 7, 9:02 am, Ambika Kulkarni <[email protected]> wrote:
> Hey Sana,
>
> function fetchData()
>         {
>          $this->loadModel('MainCategory','MenuItem','GroupUser','User');
>          $main_category  = $this->query("SELECT mi.*, ga.* FROM menu_items as
> mi
>
>                                 LEFT JOIN group_access as ga ON 
> mi.menu_item_id = ga.menu_item_id
>
>                                 LEFT JOIN group_users as gu ON ga.group_id = 
> gu.group_id
>
>                                 LEFT JOIN users as u ON gu.user_id = u.user_id
>
>                                 WHERE u.user_id = '$user_id'
>
>                                 ORDER BY mi.order");
>          $this->set('main_category',$main_category);
>          }
>
> in the fetch data method i put the above code. n its not taking value
> for user_id. Inspite of that if i put 1 the query will work n gives an
> array as o/p.

That's because $user_id isn't defined in the function. Try using $this-
>Auth->user('id') instead.

And, as Jeremy suggests, try using Cake's find() method and allowing
the associations to do their work.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

To unsubscribe, reply using "remove me" as the subject.

Reply via email to