小编Iso*_*lde的帖子

zendframework 2选择列的最大值

我正在使用ZendFramework 2和TableGateway,它适用于普通的select语句.但我似乎无法找到如何使用ZendFramework 2选择获得最大列.我的选择看起来应该是这样的

SELECT MAX( `publication_nr` ) AS maxPubNr FROM `publications` 
Run Code Online (Sandbox Code Playgroud)

我的代码看起来像:

use Zend\Db\TableGateway\TableGateway;
class PublicationsTable
{
protected $tableGateway;
...
public function getMaxPubicationNr()
{
    $rowset = $this->tableGateway->select(array('maxPubNr' => new Expression('MAX(publication_nr)')));
    $row = $rowset->current();
    if (!$row) {
        throw new \Exception("Could not retrieve max Publication nr");
    }
    return $row;
}
Run Code Online (Sandbox Code Playgroud)

select max zend-framework2

3
推荐指数
1
解决办法
3683
查看次数

标签 统计

max ×1

select ×1

zend-framework2 ×1