So here is a method I have in my controller:
private $_tables = array();
private function _getTable($table)
{
if (!isset($this->_tables[$table])) {
include APPLICATION_PATH . '/modules/'
. $this->_request->getModuleName() . '/models/' . $table . '.php';
$this->_tables[$table] = new $table();
}
return $this->_tables[$table];
}
I'm using it like this in controller actions:
public function pageAction()
{
$request = $this->getRequest();
$pages = $this->_getTable('Pages');
$p = $pages->getSingle($request->getParam('id'));
// increment number of views in the database
// it only gets incremented when IP is not the same
// as last viewer's IP
$pages->viewIncrement($p->id);
$this->view->headTitle($p->title
. ' - Some cool title');
$this->view->p = $p;
}
It works great on localhost when testing on my PC. It also worked on my older web host but recently I have moved my ZF applications to a new web hosting provider and when viewing certain pages I get this error:
Method "_getTable" does not exist and was not trapped in __call()
That's all that's displayed, there is nothing else. Some pages work though and some show this error so I'm completely lost. What could be the problem?
All required PHP extensions are installed and configured correctly, database connection works fine (because some pages work ok). I really have no idea. If at least the error was more descriptive.