Ok, this is not "enought cake" but is the fastest way of doing it:

SELECT t.name, sum(t.id) FROM posts p INNER JOIN tags_posts tpON
(p.id=tp.post_id) INNER JOIN tags ON (t.id=tp.tag_id)
GROUP BY t.id

If you put that group in your Model::find() you'll get the best
performance you can. Databases are extremely optimized. I think it'll
be better than reorering an array in memory (even with those Set
methods).

If you benchmark it, let me know!!

On Aug 4, 4:03 pm, spongs <spongs...@gmail.com> wrote:
> Thanks for the assistance. The problem with using a foreach loop to format
> the array, seems to be quite inefficient and meant the page was taking over
> 30secs to load.
>
> I solved it like this:
>
> $arrListVals = Set::combine($Array, '{n}.' . $ModelName . '.id', '{n}.' .
> $ModelName);
>
> Cheers.
>
> --
> View this message in 
> context:http://cakephp.1045679.n5.nabble.com/Formatting-Arrays-tp1289583p4667...
> Sent from the CakePHP mailing list archive at Nabble.com.

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

Reply via email to