Reorder and new queries, also change to Query/Builder

This commit is contained in:
2023-02-28 23:47:02 -03:00
parent 849d42ea57
commit d266008224
33 changed files with 839 additions and 612 deletions

View File

@ -0,0 +1,8 @@
<?php
namespace ProVM\Database\Query\MySQL;
use ProVM\Implement\Database\Query;
class Create extends Query\Create
{
}

View File

@ -1,7 +1,8 @@
<?php
namespace ProVM\Database\Query\MySQL;
use ProVM\Alias\Database\Query\Delete as Base;
use ProVM\Implement\Database\Query;
class Delete extends Base
{}
class Delete extends Query\Delete
{
}

View File

@ -0,0 +1,8 @@
<?php
namespace ProVM\Database\Query\MySQL;
use ProVM\Implement\Database\Query;
class Drop extends Query\Drop
{
}

View File

@ -1,7 +1,8 @@
<?php
namespace ProVM\Database\Query\MySQL;
use ProVM\Alias\Database\Query\Insert as Base;
use ProVM\Implement\Database\Query;
class Insert extends Base
{}
class Insert extends Query\Insert
{
}

View File

@ -1,9 +1,9 @@
<?php
namespace ProVM\Database\Query\MySQL;
use ProVM\Alias\Database\Query\Select as Base;
use ProVM\Implement\Database\Query;
class Select extends Base
class Select extends Query\Select
{
public function limit(int $limit, ?int $offset = null): Select
{
@ -13,38 +13,45 @@ class Select extends Base
}
return $this;
}
protected int $limit;
public function setLimit(int $limit): Select
{
$this->limit = $limit;
return $this;
}
protected int $offset;
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 setLimit(int $limit): Select
{
$this->limit = $limit;
return $this;
}
public function setOffset(int $offset): Select
{
$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
{
$query = [parent::build()];
if (isset($this->limit)) {
$query []= 'LIMIT';
$query []= $this->getLimit();
if (isset($this->offset)) {
$query []= 'OFFSET';
$query []= $this->getOffset();
}
}
return implode(' ', $query);
$query = [
parent::build(),
$this->getLimitString()
];
return implode('', $query);
}
}

View File

@ -0,0 +1,8 @@
<?php
namespace ProVM\Database\Query\MySQL;
use ProVM\Implement\Database\Query;
class Truncate extends Query\Truncate
{
}

View File

@ -1,7 +1,8 @@
<?php
namespace ProVM\Database\Query\MySQL;
use ProVM\Alias\Database\Query\Update as Base;
use ProVM\Implement\Database\Query;
class Update extends Base
{}
class Update extends Query\Update
{
}