$this->Task->find('all', array('conditions' => array('Task.tasks_username'
=> $username)));What you can do with CakePHP is have your models use the following relationship: User hasMany Task Task belongsTo User Then in your table "tasks" you will add a field : "user_id". Then you can associate the tasks to users, so if you find a task it will find its associated user or if you find a user it will find all the tasks associated (Depending on your recursive settings). The query would be the same except "Task.user_id" => $username ... On 16 March 2011 02:58, venky <[email protected]> wrote: > Hi I have 2 models 1.Task 2.User And respective controllers > I want to retrieve tasks pertaining to a particular user while logged > in...here is the relevant php code > $query="select * from tasks where tasks_username = '$username'"; > > I want to write code in cakephp for this query. How can i write? and > in controller or model?? can you show me some sample code? > Thanks > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > [email protected] For more options, visit this group > at http://groups.google.com/group/cake-php > -- Kind Regards Stephen http://www.ninjacodermonkey.co.uk -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
