Nette\Database\Drivers\OdbcDriver::applyLimit PHP Method

applyLimit() public method

Injects LIMIT/OFFSET to the SQL query.
public applyLimit ( &$sql, $limit, $offset )
    public function applyLimit(&$sql, $limit, $offset)
    {
        if ($offset) {
            throw new Nette\NotSupportedException('Offset is not supported by this database.');
        } elseif ($limit < 0) {
            throw new Nette\InvalidArgumentException('Negative offset or limit.');
        } elseif ($limit !== NULL) {
            $sql = preg_replace('#^\\s*(SELECT(\\s+DISTINCT|\\s+ALL)?|UPDATE|DELETE)#i', '$0 TOP ' . (int) $limit, $sql, 1, $count);
            if (!$count) {
                throw new Nette\InvalidArgumentException('SQL query must begin with SELECT, UPDATE or DELETE command.');
            }
        }
    }