Can't call method in model table class using Doctrine with Zend Framework
- by Jeremy Hicks
I'm using Doctrine with Zend Framework. For my model, I'm using a base class, the regular class (which extends the base class), and a table class.
In my table class, I've created a method which does a query for records with a specific value for one of the fields in my model. When I try and call this method from my controller, I get an error message saying, "Message: Unknown method Doctrine_Table::getCreditPurchases". Is there something else I need to do to call functions in my table class? Here is my code:
class Model_CreditTable extends Doctrine_Table
{
/**
* Returns an instance of this class.
*
* @return object Model_CreditTable
*/
public static function getInstance()
{
return Doctrine_Core::getTable('Model_Credit');
}
public function getCreditPurchases($id)
{
$q = $this->createQuery('c')
->where('c.buyer_id = ?', $id);
return $q->fetchArray();
}
}
// And then in my controller method I have...
$this->view->credits = Doctrine_Core::getTable('Model_Credit')->getCreditPurchases($ns->id);