Re: Formatting Arrays

2011-08-05 Thread Santiago Basulto
My query is bugged!!! Oh lord! hehe. It was adding the ids up (don't know if that sentence is right, my english is not very good). It should COUNT insteado of SUM. SELECT t.name, COUNT(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.i

Re: Formatting Arrays

2011-08-05 Thread Jeremy Burns | Class Outfit
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 fiel

Re: Formatting Arrays

2011-08-05 Thread Santiago Basulto
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 ar

Re: Formatting Arrays

2011-08-04 Thread spongs
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. -- Vie

Re: Formatting arrays returned using Find('all')

2011-08-04 Thread Ceeram
why did you double post this? Set::extract('{n}.Industry', $your_data); -- 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 fr

Re: Formatting Arrays

2011-08-04 Thread Ceeram
Set::extract('{n}.Industry', $your_data); -- 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 ca

Re: Formatting arrays returned using Find('all')

2011-08-04 Thread Miles J
Is there a reason you need to condense it? Isn't that much work. foreach ($items as $item) { echo $item['Industry']['id']; } On Aug 4, 5:48 am, spongs101 wrote: > Perhaps using Set::Format or another method.  Can anyone describe an > efficient way of converting the following array.  In reality

Re: Formatting Arrays

2011-08-04 Thread Tilen Majerle
or this like you Peter said :) -- Lep pozdrav, Tilen Majerle http://majerle.eu 2011/8/4 Peter Meth > wouldn't this do it?? > > foreach($myarray as $key => $subarray) { >$myarray[$key] = $myarray[$key]['Industry']; > } > > On Aug 4, 2:32 pm, Tilen Majerle ..@gmail.com> > wrote: > > $ne

Re: Formatting Arrays

2011-08-04 Thread Peter Meth
wouldn't this do it?? foreach($myarray as $key => $subarray) { $myarray[$key] = $myarray[$key]['Industry']; } On Aug 4, 2:32 pm, Tilen Majerle wrote: > $new = array(); > foreach ($old as $tmp) > { >    $new[] = $tmp['Imdustry']; > > } > > -- > Lep pozdrav, Tilen Majerlehttp://majerle.eu

Re: Formatting Arrays

2011-08-04 Thread Tilen Majerle
$new = array(); foreach ($old as $tmp) { $new[] = $tmp['Imdustry']; } -- Lep pozdrav, Tilen Majerle http://majerle.eu 2011/8/4 spongs > Can anybody help, similar to the above... > > Need a quick way of turning this: > > Array > ( >[0] => Array >( >[Industry] => Arra

Re: Formatting Arrays

2011-08-04 Thread spongs
Can anybody help, similar to the above... Need a quick way of turning this: Array ( [0] => Array ( [Industry] => Array ( [id] => 1 [industry] => Basic Materials [ShowInLists] => 1 )

Re: Formatting Arrays

2008-02-22 Thread Ape
be cool, and share your knowledge. > > BAKE ON! > > blog:http://www.MarianoIglesias.com.ar > > -Mensaje original- > De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre > de Chris Hartjes > Enviado el: Jueves, 21 de Febrero de 2008 07:28 p.m. > Para: cake

Re: Formatting Arrays

2008-02-21 Thread Samuel DeVore
somebody please document that juicy piece of sexy in the 'book' On Thu, Feb 21, 2008 at 4:15 PM, Chris Hartjes <[EMAIL PROTECTED]> wrote: > > On Thu, Feb 21, 2008 at 7:04 PM, Mariano Iglesias > <[EMAIL PROTECTED]> wrote: > > > > Set::combine($data, '{n}.Tag.tag_name', '{n}.Tag.tag_count'); >

Re: Formatting Arrays

2008-02-21 Thread Chris Hartjes
On Thu, Feb 21, 2008 at 7:04 PM, Mariano Iglesias <[EMAIL PROTECTED]> wrote: > > Set::combine($data, '{n}.Tag.tag_name', '{n}.Tag.tag_count'); > > Ain't that just freaking sexy > I keep forgetting about Set::combine()... Thanks Mariano. -- Chris Hartjes Internet Loudmouth Motto for 2008: "Mo

RE: Formatting Arrays

2008-02-21 Thread Mariano Iglesias
de Febrero de 2008 07:28 p.m. Para: cake-php@googlegroups.com Asunto: Re: Formatting Arrays On Thu, Feb 21, 2008 at 5:15 PM, Ape <[EMAIL PROTECTED]> wrote: > Can anyone help me? > > Thanx in advance, > > Ape Read up on how to use Set::extract --~--~-~--~~-

Re: Formatting Arrays

2008-02-21 Thread Chris Hartjes
On Thu, Feb 21, 2008 at 5:15 PM, Ape <[EMAIL PROTECTED]> wrote: > Can anyone help me? > > Thanx in advance, > > Ape Read up on how to use Set::extract -- Chris Hartjes Internet Loudmouth Motto for 2008: "Moving from herding elephants to handling snakes..." @TheKeyBoard: http://www.littlehart