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(); }