Skip to content

Commit

Permalink
Update Table.php
Browse files Browse the repository at this point in the history
noLimit()
  • Loading branch information
secure73 authored Jul 1, 2024
1 parent 3567e89 commit 35be869
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/core/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Table extends PdoQuery
/**
* @var array<mixed> $_binds
*/
private bool $_no_limit;
private array $_binds;
private int $_limit;
private int $_offset;
Expand All @@ -29,6 +30,7 @@ public function __construct()
$this->_orderBy = '';
$this->_isSelectSet = false;
$this->_limit = $_ENV['QUERY_LIMIT'];
$this->_no_limit = false;
$this->_offset = 0;
$this->_query = null;
$this->_binds = [];
Expand Down Expand Up @@ -116,6 +118,12 @@ public function limit(int $limit): self
return $this;
}

public function noLimit():self
{
$this->_no_limit = true;
return $this;
}

/**
* @param string $column
* @param mixed $value
Expand Down Expand Up @@ -211,7 +219,15 @@ public function run(): false|array
$this->_query = $this->_query .
" , (SELECT COUNT(*) FROM {$this->getTable()} {$this->whereMaker()} ) AS _total_count FROM {$this->getTable()} {$this->whereMaker()} ";

$this->_query .= $this->_orderBy . " LIMIT $this->_limit OFFSET $this->_offset ";
if($this->_no_limit)
{
$this->_query .= $this->_orderBy . " LIMIT $this->_limit OFFSET $this->_offset ";
}
else
{
$this->_query .= $this->_orderBy;
}

$this->_query = trim($this->_query);
$this->_query = preg_replace('/\s+/', ' ', $this->_query);
if (!$this->_query) {
Expand Down

0 comments on commit 35be869

Please sign in to comment.