i have:
public function executeTest(sfWebRequest $request)
{
$query = Doctrine_Query::create()
->from('Messages')
->where('id = ?', $id);
$query->fetchArray();
}
i did function in lib/model:
public function newfunction($id)
{
$query = Doctrine_Query::create()
->from('Messages')
->where('id = ?', $id);
return $query->fetchArray();
}
and now have:
public function executeTest(sfWebRequest $request)
{
$this->newfunction($id);
}
but i have error:
sfException: Call to undefined method messagesActions::newfunction.
if :
public function executeTest(sfWebRequest $request)
{
$this->newfunction($id);
}
i have
Fatal error: Call to a member function newFunction() on a non-object in
What can I do?
I’m assuming you created
newFunctioninlib/model/MessagesTable.class.php.$this->newFunction()won’t work, because$thisrefers to the current action instance, not your model’s table. You need to use either:or
they both do the same thing, so it’s just a matter of preference.
Also, you do not set a value for
$idin your action’s code.