Hi Brian and Adam:
Thanx for your help, very much. I've got
it working now, using your codes 'combined'.
-sam
On Jun 17, 12:34 am, brian <[email protected]> wrote:
> On Tue, Jun 16, 2009 at 9:44 PM, Adam Royle<[email protected]> wrote:
>
> > $this->set() doesn't return a value. so $transaction_amount_total will be
> > null. Try something like this:
>
> > $data = $this->Jurisdiction->Transaction->find('all', array(
> > 'conditions' => array('Transaction.jurisdiction_id =' => $id),
> > 'fields' => array('Transaction.id','SUM(Transaction.amount) AS Amount'))
> > ));
>
> > $transaction_amount_total = $data[0][0]['Amount'];
>
> > $this->set('transaction_amount_total, $transaction_amount_total);
>
> The last 2 lines can be simplified a wee bit:
>
> $this->set('transaction_amount_total, $data[0][0]['Amount']);
>
> Or:
>
> $transaction_amount_total = $data[0][0]['Amount'];
> $this->set(compact('transaction_amount_total'), false);
>
> Note the false param for set. That's required when using compact() and
> a var name with underscores. Otherwise, Cake will unleash Inflector on
> it, making it camel-cased.
>
> I have to confess that I'm a bit confused as to what the original
> issue was in this thread. If it's just that Cake isn't putting the
> calculated field under the modelName key in the $data array, you
> should check out this tip:
>
> http://teknoid.wordpress.com/2008/09/29/dealing-with-calculated-field...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---