> How slow. Feel free to propose an alternative that achieves the same
> thing.
Okay, well, I researched IN again and it appears that IN is really
only slow in sub-selects where a join would be much faster. Sorry, I
posted without double-checking, I conflated sub-selects with any
select ;(
> So don't ask for it :)
That's the problem isn't it - figuring out the best way not to ask for
it :P
> Post hasOne Comment would generate that - but good luck paginating it.
> As soon as any post has more than 1 comment your post index is going
> to have duplicates or holes (depending on if/how you try to 'fix'
> that). But why are you requesting comments at all?
Well, I'd like to list the amount of comments each post has on the
main page. There might be another way to get this, but it still irks
me that Cake produces two queries when one query would suffice. I
thought using a join in this case would be the obvious choice for
Cake's ORM (does it have an official name? ActiveCake?).
I thought about overriding the paginate method in my Post model, but
the extra query only adds about 1-5ms of time and the records are
limited to 20 so IN wouldn't be terribly slow, so I'll probably ignore
this issue for now. In the future I'll probably just implement my own
pagination separate from Cake itself.
>Probably because he doesn't know about recursion (yet)?
>A find('all') command will do exaclty that, find all... So if you do a
>find('all') of the posts, itll also get all the commens, tags, users,
>whatever the post has relationships with... If in a certain action you
>just need the posts, add $this->Product->recursive = 0; before the
>call. It'll limit the search to only posts. (recursive is kinda like a
>depth-level of search)
I'm not sure if reducing recursion would help me here. I actually
*want* those comments - or at least their count for each post.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---