Hi I'm porting some apps to CakePHP and experimenting with the GROUP BY used by this framework. Having a find('all', $c) with $c=array( array( 'Client.id', 'Client.name', 'Transaction.data', 'Transaction.conteggiato', 'Transaction.riscosso', 'Transaction.id', 'Type.id', 'Type.title', 'Currency.symbol', 'SUM(Transaction.import) as importo' ), 'group' => array('MONTH(Transaction.data)');
This code block returns an array that's (imho) wrongly indexed. It returns something like $results = 'Transaction' => array('id', 'title') 'Type' => array('id', 'title') '0' => array('import') This means it puts the fields affected by the SUM() function in a different array indexed as "0" (zero) and not in the right one (Transaction). Is this a normal behaviour of Cakephp or not? I've fixed the thing with this code inside afterFind($results) { foreach($results as $k => $r) { if (isset($r[0])) { foreach($r[0] as $k2 => $v2) $results[$k] ['Transaction'][$k2]=$v2; unset($results[$k][0]); } } Thanks ark0n3 --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---