Reputation: 36219
I have a generic model called MyWork_Model_Base that extends Zend_Db_Table_Abstract. All my models then extend MyWork_Model_Base. Is there a way I can add a code to this Model_Base so that it runs every time after the model function is executed?
Thanks
Upvotes: 1
Views: 59
Reputation: 4625
You can add the code to the __destruct
function of the MyWork_Model_Base
class. The destructor will be executed every time the function is executed
class Model_User extends MyWork_Model_Base
{
public function getUserDetails()
{
$select = $this->select();
$this->column = 'user_id';
$this->value = '9999';
return $this->fetchAll($select);
}
}
class MyWork_Model_Base extends Zend_Db_Table_Abstract
{
.
.
.
public function fetchAll($select)
{
return parent::fetchAll($select);
}
public function __destruct()
{
echo 'Destruct Called : '.$this->column.'//'.$this->value.' <br/>';
}
}
Upvotes: 1