我正在使用Zend框架中的理论。对于我的模型,我使用的是基类、常规类(扩展了基类)和表类。
在我的表类中,我创建了一个方法,用于查询模型中某个字段具有特定值的记录。当我尝试从我的控制器调用这个方法时,我收到一条错误消息,上面写着:“消息:未知方法原理_table::getCreditPurchases”。在我的表类中,还有什么我需要做的来调用函数吗?这是我的代码:
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);