Files
query_builder/src/Implement/Query/MySQL/Select.php
2025-09-29 16:40:43 -03:00

65 lines
1.4 KiB
PHP

<?php
namespace Database\Implement\Query\MySQL;
use Database\Ideal\Query;
class Select extends Query\Select
{
public function limit(int $limit, ?int $offset = null): self
{
$this->setLimit($limit);
if ($offset !== null) {
$this->setOffset($offset);
}
return $this;
}
public function getTable(): string
{
$table = parent::getTable();
return "`{$table}`";
}
protected int $limit;
protected int $offset;
public function getLimit(): int
{
return $this->limit;
}
public function getOffset(): int
{
return $this->offset;
}
public function setLimit(int $limit): self
{
$this->limit = $limit;
return $this;
}
public function setOffset(int $offset): self
{
$this->offset = $offset;
return $this;
}
protected function getLimitString(): string
{
return (isset($this->limit)) ? " LIMIT {$this->getLimit()}{$this->getOffsetString()}" : '';
}
protected function getOffsetString(): string
{
return (isset($this->offset)) ? " OFFSET {$this->getOffset()}" : '';
}
public function build(): string
{
return parent::build();
/*$query = [
parent::build(),
$this->getLimitString()
];
return implode('', $query);*/
}
}