picodb(mssql): teach picodb to use TOP for limits on MSSQL
This commit is contained in:
committed by
Frédéric Guillot
parent
5493c2997e
commit
37bc859df5
@@ -119,6 +119,14 @@ class Table
|
||||
*/
|
||||
private $sqlSelect = '';
|
||||
|
||||
/**
|
||||
* SQL TOP clause
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $sqlTop = '';
|
||||
|
||||
/**
|
||||
* SQL joins
|
||||
*
|
||||
@@ -578,7 +586,11 @@ class Table
|
||||
public function limit($value)
|
||||
{
|
||||
if (! is_null($value)) {
|
||||
$this->sqlLimit = ' LIMIT '.(int) $value;
|
||||
if ($this->db->getDriver()->useTop) {
|
||||
$this->sqlTop = ' TOP ('.(int) $value.') ';
|
||||
} else {
|
||||
$this->sqlLimit = ' LIMIT '.(int) $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -693,7 +705,8 @@ class Table
|
||||
$this->groupBy = $this->db->escapeIdentifierList($this->groupBy);
|
||||
|
||||
return trim(sprintf(
|
||||
'SELECT %s FROM %s %s %s %s %s %s %s',
|
||||
'SELECT %s %s FROM %s %s %s %s %s %s %s',
|
||||
$this->sqlTop,
|
||||
$this->sqlSelect,
|
||||
$this->db->escapeIdentifier($this->name),
|
||||
implode(' ', $this->joins),
|
||||
|
||||
Reference in New Issue
Block a user