Query "Factory"
This commit is contained in:
37
src/Database/QueryBuilder.php
Normal file
37
src/Database/QueryBuilder.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
namespace ProVM\Database;
|
||||||
|
|
||||||
|
use Psr\Container\ContainerInterface;
|
||||||
|
use ProVM\Concept\Database\QueryBuilder as QBInterface;
|
||||||
|
use ProVM\Concept\Database\Query\{Delete,Insert,Select,Update};
|
||||||
|
|
||||||
|
class QueryBuilder implements QBInterface
|
||||||
|
{
|
||||||
|
protected ContainerInterface $container;
|
||||||
|
public function setContainer(ContainerInterface $container): QBInterface
|
||||||
|
{
|
||||||
|
$this->container = $container;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
public function getContainer(): ContainerInterface
|
||||||
|
{
|
||||||
|
return $this->container;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function select(array $columns = ['*']): Select
|
||||||
|
{
|
||||||
|
return $this->getContainer()->get(Select::class)->select($columns);
|
||||||
|
}
|
||||||
|
public function insert(string $table): Insert
|
||||||
|
{
|
||||||
|
return $this->getContainer()->get(Insert::class)->into($table);
|
||||||
|
}
|
||||||
|
public function update(string $table): Update
|
||||||
|
{
|
||||||
|
return $this->getContainer()->get(Update::class)->table($table);
|
||||||
|
}
|
||||||
|
public function delete(string $table): Delete
|
||||||
|
{
|
||||||
|
return $this->getContainer()->get(Delete::class)->from($table);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user