Monday, November 30, 2009

Re: Most concise and complete Recursive Association Support in CakePHP?

Thanks for the replies so far. To answer the question about relations,
this would be something like the following:

A User as has a Profile, a Rank and multiple Ratings and multiple
Tags, which are indexed in a lookup table called Tagtaxonomy. These
Ratings are in turn related to Posts.

I would like to retrieve a user along with its rank, average rating
and concatenated list of tags. It's possible to do this in one SQL
query, but the way I set a test scenario up, Cake does it by issuing
multiple SELECT statements on multiple tables.

Hope this clarifies my initial question a bit more.


On Nov 27, 6:56 pm, John Andersen <j.andersen...@gmail.com> wrote:
> Please specify how your Users, Profiles, Ranks and Ratings are
> related, then we may better be able to assist you ;)
> Enjoy,
>    John
>
> On Nov 26, 6:48 pm, mensch <majesteitmen...@gmail.com> wrote:
>
>
>
> > I've asked this question on StackOverflow as well, but I thought I
> > might some more answers closer to the source. I'm currently mucking
> > about with CakePHP, deciding if I'll use it in an upcoming web
> > application.
>
> > The problem is, I've got several tables which at some point share
> > relevant data with each other. If I were to write all the code myself
> > I would use an SQL query using rather a lot of different joins and
> > subqueries. But from what I understand CakePHP only supports joins
> > between two tables.
>
> > So for example, I have Users, Profile, Rank, Rating tables and I want
> > to get the profile, rank and ratings of one particular user. CakePHP
> > will do the trick by using multiple, separate SELECT statements. But
> > this would be possible using one query with multiple joins.
> > Performance is expected to be quite important, so not being too
> > wasteful with SQL queries is a major perquisite.
>
> > I've found two hacks (<a href="http://lloydhome.com/blog/development/
> > 2009/recursive-association-support-cakephp-12">one behaviour</a> and
> > <a href="http://mark-story.com/posts/view/using-bindmodel-to-get-to-
> > deep-relations">one using bindModel</a>) and <a href="http://
> > stackoverflow.com/questions/806650/in-cakephp-how-to-retrieve-joined-
> > result-from-multiple-tables">a StackOverflow thread</a>.
>
> > I'm undecided whether to use the behaviour or the bindModel hack.
> > Could anybody shed any light as to what is the best approach - viz.
> > what integrates best in the overall CakePHP structure (are features
> > like pagination still available)? Or is there another approach which
> > is ultimately better. The aformentioned SO thread mentions a method
> > using containables.

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

No comments: