van*_*gen 1 sql zend-framework2
e:刚刚意识到这可能与SQL Server的事实有关.有人知道ZF2相当于SQL Server的LIMIT吗?
嗨,大家好,
一如既往地坚持使用ZF2.
我在一个类中有一个fetchAll()方法,它从某个表中选择行.现在,该方法有效,但我似乎无法限制它.
这工作(并以正确的顺序返回行):
public function fetchAll()
{
$resultSet = $this->tableGateway->select(function(Select $select){
$select->order('messageId ASC');
});
return $resultSet;
}
Run Code Online (Sandbox Code Playgroud)
但根据我的理解,限制应该相当容易(和类似),所以我这样做(这不起作用):
public function fetchAll()
{
$resultSet = $this->tableGateway->select(function(Select $select){
$select->limit(30);
});
return $resultSet;
}
Run Code Online (Sandbox Code Playgroud)
它现在没有返回任何东西.我究竟做错了什么?
小智 6
使用offset()
public function fetchAll()
{
$resultSet = $this->tableGateway->select(function(Select $select){
$select
->limit(30)
->offset(10);
});
return $resultSet;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9525 次 |
| 最近记录: |