MySQL Queries
This commit is contained in:
7
src/Database/Query/MySQL/Delete.php
Normal file
7
src/Database/Query/MySQL/Delete.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
namespace ProVM\Database\Query\MySQL;
|
||||
|
||||
use ProVM\Alias\Database\Query\Delete as Base;
|
||||
|
||||
class Delete extends Base
|
||||
{}
|
7
src/Database/Query/MySQL/Insert.php
Normal file
7
src/Database/Query/MySQL/Insert.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
namespace ProVM\Database\Query\MySQL;
|
||||
|
||||
use ProVM\Alias\Database\Query\Insert as Base;
|
||||
|
||||
class Insert extends Base
|
||||
{}
|
50
src/Database/Query/MySQL/Select.php
Normal file
50
src/Database/Query/MySQL/Select.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
namespace ProVM\Database\Query\MySQL;
|
||||
|
||||
use ProVM\Alias\Database\Query\Select as Base;
|
||||
|
||||
class Select extends Base
|
||||
{
|
||||
public function limit(int $limit, ?int $offset = null): Select
|
||||
{
|
||||
$this->setLimit($limit);
|
||||
if ($offset !== null) {
|
||||
$this->setOffset($offset);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
protected int $limit;
|
||||
public function setLimit(int $limit): Select
|
||||
{
|
||||
$this->limit = $limit;
|
||||
return $this;
|
||||
}
|
||||
public function getLimit(): int
|
||||
{
|
||||
return $this->limit;
|
||||
}
|
||||
protected int $offset;
|
||||
public function setOffset(int $offset): Select
|
||||
{
|
||||
$this->offset = $offset;
|
||||
return $this;
|
||||
}
|
||||
public function getOffset(): int
|
||||
{
|
||||
return $this->offset;
|
||||
}
|
||||
|
||||
public function build(): string
|
||||
{
|
||||
$query = [parent::build()];
|
||||
if (isset($this->limit)) {
|
||||
$query []= 'LIMIT';
|
||||
$query []= $this->getLimit();
|
||||
if (isset($this->offset)) {
|
||||
$query []= 'OFFSET';
|
||||
$query []= $this->getOffset();
|
||||
}
|
||||
}
|
||||
return implode(' ', $query);
|
||||
}
|
||||
}
|
7
src/Database/Query/MySQL/Update.php
Normal file
7
src/Database/Query/MySQL/Update.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
namespace ProVM\Database\Query\MySQL;
|
||||
|
||||
use ProVM\Alias\Database\Query\Update as Base;
|
||||
|
||||
class Update extends Base
|
||||
{}
|
Reference in New Issue
Block a user