0

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?

1 Answer 1

2

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.