Is there any advantage of using the following way to fetch Model?

TheBigK

Well-known member
#1
Can someone tell me if there's any advantage in using any of the following ways to fetch a model?

PHP:
public function actionIndex()
{
 $myModel = $this->_getMyModel()
}
protected function _getMyModel()
{
return $this->getModelFromCache('MyAddon_Model_MyModel');
}
and
PHP:
public function actionIndex()
{
 $myModel = $this->getModelFromCache('MyAddon_Model_MyModel'); 
}
 

batpool52!

Well-known member
#2
None really. If the model is being used twice in different functions then I use the first method
PHP:
public function actionIndex()
{
    $myModel = $this->_getMyModel()
}
protected function _getMyModel()
{
    return $this->getModelFromCache('MyAddon_Model_MyModel');
}
and if the model is being used just once then I use the second method
PHP:
public function actionIndex()
{
    $myModel = $this->getModelFromCache('MyAddon_Model_MyModel');
}
 
Top