1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-16 19:14:17 +02:00

DibiFluent::fetch(): fixed limit clause duplication [Closes #188][Closes #186][Closes #185]

This commit is contained in:
castamir
2015-10-07 16:38:35 +02:00
committed by David Grudl
parent e3748420f5
commit 2d9358e4f7
3 changed files with 103 additions and 9 deletions

View File

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