我有一个ContactsTable.php模块和功能如下:Zend2 TableGateway:如何获取一组数据
public function getContactsByLastName($last_name){
$rowset = $this->tableGateway->select(array('last_name' => $last_name));
$row = $rowset->current();
if (!$row) {
throw new \Exception("Could not find row record");
}
return $row;
}
这是确定的,但它只返回一行。 问题是在我的数据库中我有多个记录具有相同的姓氏,所以我的问题是: 如何返回一组数据?
我尝试这样做:
$where = new Where();
$where->like('last_name', $last_name);
$resultSet = $this->tableGateway->select($where);
return $resultSet;
,但它不工作。