开发者

Binding a doctrine_record class to a query result

I just started out with Doctrine and it has been awesome so far. I have a little challenge though.

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';
   }
}

Calling the getDateRegistered function results in an undefined method error. Coming from a Zend Background, This is taken care of by writing your table queries like this

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

Can I do something Like this in Doctrine? Specifying the Row Class while querying the table? Thank you

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜