Because flash expects a string.
If you're going to use query() for this I think you'd be better off
calling stored procedures. Or, put another way, I think you'd be
better off using stored procedures.
That is, if your model's logic doesn't also include some need to loop
over the Customerpurchase data and do other stuff. If you do, then use
a regular find() and sum your total in afterFind() so you have
something like this:
'Customerpurchase' => array(
0 => array( ... ),
1 => array( ... ),
'total' => $the_total
On Fri, Apr 20, 2012 at 2:27 AM, jasonix <jayhinanay@xxxxxxxxx> wrote:
> hi, i'm newby in using cakePHP.
> i have 2 tables: customerbills and customerpurchases.
> what i want to do is to make a sum query in customerpurchases and
> update it in customerbills.
> customerpurchases fields:
> customerbills fields:
> Here's what i did in my customerpurchasesController:
> $billid = 1;
> $total = $this->Customerpurchase->query("SELECT
> SUM(customerpurchases.amount) AS total From customerpurchases Group by
> customerbill_id = $billid");
> now i try this for updating:
> $this->Customerpurchase->query("UPDATE bills SET amountbill = $total
> Where id = $billid");
> but i it doesn't work. I tried to display the variable $total in
> session flash to check what's inside the variable and it displays
> "arrays" ..
> pls. help me. Thanks..
> Our newest site for the community: CakePHP Video Tutorials
> 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
> cake-php+unsubscribe@xxxxxxxxxxxxxxxx For more options, visit this group at
Our newest site for the community: CakePHP Video Tutorials
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
cake-php+unsubscribe@xxxxxxxxxxxxxxxx For more options, visit this group at