Symfony app - how to add calculated fields to Propel objects?
Posted
by Thomas Kohl
on Stack Overflow
See other posts from Stack Overflow
or by Thomas Kohl
Published on 2008-10-29T10:56:19Z
Indexed on
2010/03/26
13:23 UTC
Read the original article
Hit count: 410
What is the best way of working with calculated fields of Propel objects?
Say I have an object "Customer" that has a corresponding table "customers" and each column corresponds to an attribute of my object. What I would like to do is: add a calculated attribute "Number of completed orders" to my object when using it on View A but not on Views B and C.
The calculated attribute is a COUNT() of "Order" objects linked to my "Customer" object via ID.
What I can do now is to first select all Customer objects, then iteratively count Orders for all of them, but I'd think doing it in a single query would improve performance. But I cannot properly "hydrate" my Propel object since it does not contain the definition of the calculated field(s).
How would you approach it?
© Stack Overflow or respective owner