src/AbstractDbEntityFetcher.php
protected function getLimitSql($limit, array $pageItem = [])
    {
        $limitSql = '';
        if (!empty($limit) || !empty($pageItem)) {
            $limitSql = 'LIMIT ';
            if (!empty($pageItem)) {
                list($pageNo, $rowsPerPage) = $pageItem;

                $pageNo = (int) $pageNo;
                if ($pageNo < 1) {
                    throw new \InvalidArgumentException("Invalid pagination page number \"{$pageNo}\"");
                }
                $rowsPerPage = (int) $rowsPerPage;

                // Offset example: "10" skips the first 10 rows, start showing the 11th
                $offset = ($pageNo - 1) * $rowsPerPage;
                $limitSql .= sprintf('%d, %d', $offset, $rowsPerPage);
            } else {
                $limitSql .= (int) $limit;
            }
        }

        return $limitSql;
    }
protected function getLimitSql($limit, array $pageItem = [])
    {
        $limitSql = '';
        if (!empty($limit) || !empty($pageItem)) {
            $limitSql = 'LIMIT ';
            if (!empty($pageItem)) {
                list($pageNo, $rowsPerPage) = $pageItem;

                $pageNo = (int) $pageNo;
                if ($pageNo < 1) {
                    throw new \InvalidArgumentException("Invalid pagination page number \"{$pageNo}\"");
                }
                $rowsPerPage = (int) $rowsPerPage;

                // Offset example: "10" skips the first 10 rows, start showing the 11th
                $offset = ($pageNo - 1) * $rowsPerPage;
                $limitSql .= sprintf('%d, %d', $offset, $rowsPerPage);
            } else {
                $limitSql .= (int) $limit;
            }
        }

        return $limitSql;
    }
protected function getLimitSql ( $ limit , array $ pageItem = [ ] ) { $ limitSql = '' ; if ( ! empty ( $ limit ) || ! empty ( $ pageItem ) ) { $ limitSql = 'LIMIT ' ; if ( ! empty ( $ pageItem ) ) { list ( $ pageNo , $ rowsPerPage ) = $ pageItem ; $ pageNo = ( int ) $ pageNo ; if ( $ pageNo < 1 ) { throw new \ InvalidArgumentException ( "Invalid pagination page number \"{$pageNo}\"" ) ; } $ rowsPerPage = ( int ) $ rowsPerPage ; // Offset example: "10" skips the first 10 rows, start showing the 11th $ offset = ( $ pageNo - 1 ) * $ rowsPerPage ; $ limitSql .= sprintf ( '%d, %d' , $ offset , $ rowsPerPage ) ; } else { $ limitSql .= ( int ) $ limit ; } } return $ limitSql ; }
Helper method to get LIMIT SQL and paging flag from limit parameter.

@param int   $limit           A limit number (like 5)
@param array $pageItem        A pagination array like [1, 10], where 1 is the page number and 10 the number of
rows per page (first page is 1).
@return string
Helper method to get LIMIT SQL and paging flag from limit parameter .