I have seen memory exhaustion using Set::extract on large (but not huge) arrays, so avoid it now unless I can be confident the array is going to be small. I completely agree that it is generally best to let the database do what it is best at. If the resulting array is only going to have two fields, I use find->list and specify the fields I want.
Jeremy Burns Class Outfit http://www.classoutfit.com On 5 Aug 2011, at 12:19, Santiago Basulto wrote: > 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 <[email protected]> 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 > [email protected] For more options, visit this group at > http://groups.google.com/group/cake-php -- 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 [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
