Imagine that I have a table called "element" in which there is a column "price". In addition to the full price, I would like to receive a price quote after 12 months, i.e.
class Item extends Doctrine_Record { ... public function getMonthlyPrice() { return $this->price/12; } }
Now, let's say, I would like the Item action as a monthly price to be just another column, and not a function call, for example,
$m = Doctrine_Core::getTable("Item")->find(1); echo $m->price;
My first instinct is to override the __get () method. Is there a better or more standard way to do this in the Doctrine?
Bonus question:
Is there some very smart way that I can set an object, so when I do
var_dump($m->getData())
I see
array 'price' => 120 'monthlyPrice' => 10
It will be pretty elegant.
source share