Sorry - but that's the wrong answer and defeats one of the main purposes of using a framework like Cake. Queries are the avenue of last resort.
First, I'd look at the conventions: http://book.cakephp.org/view/901/CakePHP-Conventions I recommend this because your campaign table should really be called campaigns. Create a model for each table. http://book.cakephp.org/view/1001/Understanding-Models Then, set up your model associations: http://book.cakephp.org/view/1039/Associations-Linking-Models-Together This effectively joins your tables together in a consistent, repeatable and re-useable manner. Then you can build structured finds really easily: http://book.cakephp.org/view/1018/find I'd really recommend you incorporate the Containable behaviour too: http://book.cakephp.org/view/1323/Containable So an example might be: $this->Campaign->find( 'all', array( 'contain' => array( 'User' ) ) ); This does a find all on the Campaign model (on the campaigns table) and includes related User records (from the users table). You can add conditions, restrict fields and do so much more from this simple set up. I know that sometimes all you want is a quick, one line answer, but if you are new to Cake I'd really recommend getting to grips with the basics. A little time invested now will reap rewards in the long term. Jeremy Burns [email protected] On 5 May 2010, at 07:31, Master Ram wrote: > Ok sir i got it > > On May 5, 11:18 am, Ramkumar Ramkumar <[email protected]> wrote: >> hey bro use the queries with joins >> >> >> >> On Wed, May 5, 2010 at 11:42 AM, Master Ram <[email protected]> wrote: >>> hi.. all i am new to cakephp. >> >>> i have table called campaign: this table containing "user_id" form >>> users table. i want to get user details form user table. and i want to >>> display the result of both table campaign and users table. >> >>> how to do. this >> >>> please help me.... >> >>> 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]<cake-php%[email protected]>For >>> more options, visit this group at >>> http://groups.google.com/group/cake-php?hl=en >> >> -- >> Thanks & Regards, >> M.Ramkumar >> >> 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 > > 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
