Monday, January 5, 2009

Re: include calculated data in the model

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 <i...@netstudio.gr> 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 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: