1
我有一个像以下在ZF2的查询:Zend框架2返回对象作为查询结果
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();
}
由于我只返回单个对象,我可以从该查询返回的对象而不是数组的[0] ??有没有办法做到这一点?