From 51adcd98e07a4e5dfe93b9021f3088cc67dfabc7 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 26 Oct 2015 15:25:52 +0100 Subject: [PATCH] DibiFluent::fetch() uses limit only when there is no LIMIT & OFFSET (fixes 20f2093 on MSSQL) --- dibi/libs/DibiFluent.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/dibi/libs/DibiFluent.php b/dibi/libs/DibiFluent.php index 7d696761..c7a35b96 100644 --- a/dibi/libs/DibiFluent.php +++ b/dibi/libs/DibiFluent.php @@ -317,12 +317,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(); } @@ -332,12 +331,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(); }