Query "Factory"

This commit is contained in:
Juan Pablo Vial
2022-09-08 17:41:37 -04:00
parent 6de6720c3e
commit c4d26fbf82

View 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);
}
}