that trigger thing is great!

I had to upgrade to MySQL 5, but I think it solved my problem.

thank you a lot!

On Jan 6, 10:54 pm, Webweave <[email protected]> wrote:
> Depends on your model. If you always fetch the data for the related
> orders, it would be fairly simple to create a "virtual field" by
> adding some code in your afterFind and/or beforeSave methods.
>
> The Unobtrusive Date Picker uses this method to create a date
> formatted date for the page to use 
> (see:http://bakery.cakephp.org/articles/view/using-the-unobtrusive-date-pi...)
>
> You could also add a trigger to your database to update a field in the
> orders table which would ensure the value matches the data (of course
> that depends on your DB, and has nothing to do with Cake).
>
> On Jan 6, 11:36 am, Yannis <[email protected]> wrote:
>
> > Thank you for the advice.
>
> > Indeed that's a solution. Do you think that's better than calculating
> > the amount on the fly?
>
> > What method should I create in the order model?
>
> > Where should I put the call to this method?
>
> > thank you again!
>
> > On Jan 6, 3:40 am, Adam Royle <[email protected]> wrote:
>
> > > Just add a physical "amount" field to your orders table, and then add
> > > a method to your Order model which calculates the order total and
> > > updates the order. Then call that method whenever you add/modify/
> > > delete your OrderProducts.
>
> > > On Jan 6, 8:21 am, Yannis <[email protected]> wrote:
>
> > > > I have this kind of db structure:
>
> > > > Each Account has many Orders.
> > > > Each Order has many OrderProducts.
> > > > OrderProduct contains fields like product name, price, quantity.
>
> > > > I want to show at the account view a list of related orders and each
> > > > order has a field "amount" which will be the sum of related
> > > > orderproducts price * quantity.
>
> > > > Is this possible? Where and how should I put the relation data?
>
> > > > thank you for any help!

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to