I'd recommend that you read the section of the online guide that deals with 
models, in particular: 
http://book.cakephp.org/view/1039/Associations-Linking-Models-Together. This 
shows how you create a model for each table and then link them together. I'd 
also look at the containable behaviour: 
http://book.cakephp.org/view/1323/Containable that helps you define very 
precisely what data you want back (which also leads to very finely tuned 
database queries).

You have to forget about recordsets. Your controller tells your model what you 
want, and the code in the model does all the hard work. You end up with a 
single nested array. By walking down the 'tree' of data you can see what 
belongs to what. Your model can do the joins for you if the data is related, or 
it can do separate queries to return unrelated data. You can either get a 
single model to append the unrelated data to an existing array and get back a 
single block of data (my preferred route) or ask the controller to trigger a 
number of separate queries and process the arrays in the controller.

Jeremy Burns
jeremybu...@me.com

On 25 Mar 2010, at 16:02, Alper K. Tunç wrote:

> Hello all,
> 
> I'm one of the latest fans of CakePHP. I met with the framework through a 
> Google search for "PHP frameworks" and looking at the features (and the cute 
> name of course) decided on CakePHP. I went through the blog tutorial and 
> studied some stuff from web. Now I feel ready to shoot with my own 
> application.
> 
> I'm an old Microsoft ASP developer. So the "recordset" metaphor comes from 
> past experience.
> 
> Let's say I'm developing a web page where I will list some forum titles and 
> some news. This means I need to access to both forums and news tables.
> But -as far as I understand- the CakePHP structure is like you create a model 
> for your table, then you create a controller for your model and finally you 
> create a view for your model and controller. How am I going to use two 
> different recordsets (tables) in the same view?
> 
> (I found some pages discussing using another model in a model and suggesting 
> that it is not good practice.)
> Indeed my question what is the best practice to do this multible recordset 
> access issue and what should be avoided explicitly?
> 
> Regards,
> Alper K. Tunç
> 
> 
> 
> 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 cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en
>  
> To unsubscribe from this group, send email to 
> cake-php+unsubscribegooglegroups.com or reply to this email with the words 
> "REMOVE ME" as the subject.

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.

Reply via email to