Thursday, October 1, 2009

Re: SQL SUM function

Hi,

debug with print_r makes one and verifies what it returned

Em 01/10/2009, às 14:46, DAM escreveu:




On Sep 30, 12:20 pm, "Edinei L. Cipriani" <phpedi...@gmail.com> wrote:
Hi,

$this->Model->find('all', array('fields' =>
array('Model.id'.'SUM(Model.price) AS price' ));

Regards

2009/9/30 DAM <damit...@gmail.com>



Thankx for answer.
I tried that but not working.

controller

$payments = $this->Payment->find('all',array('fields'=>array
('Payment.id','SUM(Payment.amount) as price')));
$this->set(compact('purchaseorders','payments'));


view

<?php foreach ($payments as $payment): ?>
<?php echo $payment['Payment']['price']; ?>
<?php endforeach;?>

result

Notice (8): Undefined index:  price [APP\views\payments\add.ctp, line
6]


why?

--
Edinei L. Cipriani
Desenvolvedor Colégio Trilingue Inovaçãowww.colegioinovacao.com.br
Cursando Sistemas de Informação  - Unoesc Chapecó 1 Período
Integrante do grupo Fool N Lost de algoritimos computacionais
Fone 49 84149086




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

No comments: