将doctrine_record类绑定到查询结果

时间:2010-10-20 05:44:01

标签: php doctrine

我刚刚开始使用Doctrine,到目前为止它已经很棒了。我有一点挑战。

class TestTable extends Doctrine_Table
{
    public function getRecent()
    {                
        return $this->createQuery('Test')->execute();    
    }   

}

class Test extends Doctrine_Record
{
   public function setTableDefinition()
   {
       $this->hasColumn('test_id', 'integer');
       $this->hasColumn('user_id', 'integer');
       $this->hasColumn('date_registered', 'timestamp');
   }

   public function getDateRegistered()
   {
       return 'formattedDate';
   }
}

调用getDateRegistered函数会导致未定义的方法错误。来自Zend背景,通过编写像这样的表查询来处理这个

$table = new Zend_Db_Table(array('name'=>TableConstants::AUTH_CODE,'rowClass'=>'AuthCode'));
  return $table->fetchRow($table->select()->where('id = ?',$id));

我可以在Doctrine中做这样的事吗?查询表时指定行类?谢谢

0 个答案:

没有答案