diff --git a/SqlBuilder.php b/SqlBuilder.php index 2e511d6..e4d2461 100644 --- a/SqlBuilder.php +++ b/SqlBuilder.php @@ -317,7 +317,10 @@ class SqlBuilder extends Component private function makeLimit(): string { - return ' LIMIT ' . $this->query->offset . ',' . $this->query->limit; + if ($this->query->offset >= 0 && $this->query->limit >= 1) { + return ' LIMIT ' . $this->query->offset . ',' . $this->query->limit; + } + return ''; } diff --git a/Traits/QueryTrait.php b/Traits/QueryTrait.php index c1fdf89..2682a9c 100644 --- a/Traits/QueryTrait.php +++ b/Traits/QueryTrait.php @@ -31,8 +31,8 @@ abstract class QueryTrait extends Component implements ActiveQueryInterface, ISq public array $select = ['*']; public array $join = []; public array $order = []; - public int $offset = 0; - public int $limit = 0; + public int $offset = -1; + public int $limit = -1; public string $group = ''; public string $from = ''; public string $alias = 't1';