Zend Framework 2将对象作为查询结果返回

I have a query in ZF2 like following:

public function BrandWallBrandsById($userId,$brandId,$startDate,$endDate)
    {
            $select = new Select();
            $select->from(array('p' => $this->table), array('id'));
            $select->join(array('b' => 'brands'), 'p.brandId = b.id', array('id','name', 'cover', 'slogan', 'startDate', 'homepage'));
            $select->columns(array(new Expression('SUM(p.points) as points'), "userId", "brandId"));
            $select->order("p.points desc");
            $select->group("p.brandId");
            $where = new Where();
            $where->notEqualTo("p.points", 0);
            $where->equalTo("p.userId", $userId);
            $where->equalTo("p.brandId", $brandId);
            $where->between("p.time", $startDate, $endDate);
            $select->where($where);
            return $this->historyTable->selectWith($select)->toArray();

    }

Since I'm returning only a single object, can I return an object from this query instead of an array[0] ?? Is there any way to do this ?

If you're expecting a signle row from your query then you can use current(). Modify the last line of your code, juste like this:

$row = $this->historyTable->selectWith($select)->current();
if(!$row){
    throw new Exception('No row found');
}
return $row;