我正在 zf2 中进行查询,然后我返回一个object(Zend\Db\ResultSet\HydratingResultSet)
我必须foreach
打开的,以便访问属性。
我想默认获取一组对象。
这是我的一些代码:
工厂
'address-mapper' => function ($serviceManager) {
$mapper = new Mapper\Address();
$mapper->setDbAdapter($serviceManager->get('Zend\Db\Adapter\Adapter'));
$mapper->setEntityPrototype(new Entity\Address);
$mapper->setHydrator(new \Zend\Stdlib\Hydrator\ClassMethods);
return $mapper;
}
查询
public function fetchById()
{
$select = $this->getSelect()->where(array('id' => $Id));
return $this->select($select);
}
这让我回来了:
object(Zend\Db\ResultSet\HydratingResultSet)[459]
protected 'hydrator' =>
object(Zend\Stdlib\Hydrator\ClassMethods)[415]
protected 'underscoreSeparatedKeys' => boolean true
private 'callableMethodFilter' =>
....
....
任何想法我需要做什么?