I've got a problem, im using Zend_Db_Table_Row to model my application. I have an object with a money property called value. It is storred as int in the database. What i want to do, is to return Zend_Currency object each time something calls for this property. Like this:
$prepayment = Zend_Db_Table_Row
$currency = $prepayment->value; // should fetch Zend_Currency instead of plain int.
I've tried to acces $this->value inside Row class but it seems not work. How can I overwrite getters for an property inside Row object? Any idea?
One way to do this is to create a view helper to convert your int value to a a Zend_Currency before displaying it :
class My_Helper_Currency extends Zend_View_Helper_Abstract
{
public function currency($value, $locale = 'fr_FR') {
$currency = new Zend_Currency($locale);
$value= $value+ 0.00;//to convert it to float
return $currency->toCurrency((float) $value);
}
}
and to display it in your view do :
echo $this->currency($my_value);