I always scratch my head when I see people resorting to $this->query... If your associations are built correctly in your models ($belongsTo, $hasMany and $hasAndBelongsToMany) you hardly ever need to use $this->query (I have only ever done it once and I'm sure I could have fixed that if I tried harder).
Jeremy Burns [email protected] On 7 Apr 2010, at 14:02, Ambika Kulkarni 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. > > > > > On Apr 7, 5:44 pm, Hani Sana <[email protected]> wrote: >> ur well come ! >> >> On Wed, Apr 7, 2010 at 5:30 PM, Ambika Kulkarni >> >> <[email protected]> wrote: >>> Hi thanks, >> >>> It worked......:) >> >>> On Wed, Apr 7, 2010 at 4:59 PM, Hani Sana <[email protected]> wrote: >> >>>> In your App controller >>>> make a >>>>>>>>>>>>> >>>> function beforeRender() >>>> { >>>> $this->____fetchData(); >>>> } >>>> below it make a function to fetch data like >>>> function __fetchData() >>>> { >>>> $this->loadModel('modelname'); >>>> $varname = $this->modelname->find('all'); >>>> $this->set('varname ',$varname; >>>> } >> >>>> I hope this will solved your problems ,try it ..............Bye. >> >>>> Check out the new CakePHP Questions sitehttp://cakeqs.organd 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 >>>> athttp://groups.google.com/group/cake-php?hl=en >> >>>> To unsubscribe, reply using "remove me" as the subject. >> >>> Check out the new CakePHP Questions sitehttp://cakeqs.organd 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 > > 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 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
