1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-18 03:41:30 +02:00

DibiFluent::fetch() uses limit only when there is no LIMIT & OFFSET (fixes 20f2093 on MSSQL)

This commit is contained in:
David Grudl
2015-10-26 15:25:52 +01:00
parent 1c3ef5f5cf
commit 63c644a860
3 changed files with 22 additions and 18 deletions

View File

@@ -316,12 +316,11 @@ class DibiFluent extends DibiObject implements IDataSource
*/
public function fetch()
{
if ($this->command === 'SELECT' && !$this->clauses['LIMIT']) {
$result = $this->query($this->limit(1)->_export())->fetch();
$this->removeClause('LIMIT');
return $result;
if ($this->command === 'SELECT' && !$this->clauses['LIMIT'] && !$this->clauses['OFFSET']) {
return $this->query($this->_export(NULL, array('%lmt', 1)))->fetch();
} else {
return $this->query($this->_export())->fetch();
}
return $this->query($this->_export())->fetch();
}
@@ -331,12 +330,11 @@ class DibiFluent extends DibiObject implements IDataSource
*/
public function fetchSingle()
{
if ($this->command === 'SELECT' && !$this->clauses['LIMIT']) {
$result = $this->query($this->limit(1)->_export())->fetchSingle();
$this->removeClause('LIMIT');
return $result;
if ($this->command === 'SELECT' && !$this->clauses['LIMIT'] && !$this->clauses['OFFSET']) {
return $this->query($this->_export(NULL, array('%lmt', 1)))->fetchSingle();
} else {
return $this->query($this->_export())->fetchSingle();
}
return $this->query($this->_export())->fetchSingle();
}