Files
query_builder/src/Database/QueryBuilder.php
Juan Pablo Vial c4d26fbf82 Query "Factory"
2022-09-08 17:42:20 -04:00

38 lines
1.1 KiB
PHP

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