The value of $total isn't hydrated because it isn't a mapped field. There are several ways to have the correct $total value when a Category is loaded, I think the most performant one is to map/persist the field. Have a look at this cookbook entry:
http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/cookbook/aggregate-fields.html -- Jasper N. Brouwer (@jaspernbrouwer) On 21 November 2014 at 11:32:46, [email protected] ([email protected]) wrote: > I have this entities: > > class Category { > // normal field database > $description; > > // hasMany Operations ArrayCollection > $operations; > > // this attribute don't field in database, this increase value when > attribute operation is setted > $total; > > public function addOperation($operation) { > $total += $operation->getValue(); > $operations[] = $operation; > } > } > > class Operation { > $description; > $value; > $category; > } > > When i execute DQL "SELECT c FROM Category", and execute > $query->getResult(Doctrine\ORM\Query::HYDRATE_ARRAY); > this attribute $total is not correct value, i understand, but i will like > know if exist any way for i intercept and observe this attribute and > increase your value. > > i have try magic methods like: __set, __call, but dont is called -- You received this message because you are subscribed to the Google Groups "doctrine-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/doctrine-user. For more options, visit https://groups.google.com/d/optout.
