Files
ulmus/src/QueryBuilder/Sql/SqliteQueryBuilder.php
T

80 lines
2.3 KiB
PHP

<?php
namespace Ulmus\QueryBuilder\Sql;
use Ulmus\Query;
use Ulmus\Adapter\AdapterInterface;
# Soon to extends SqlQueryBuilder
class SqliteQueryBuilder extends MysqlQueryBuilder
{
public function pragma(/*object|Stringable*/ $name, $value = null, bool $callable = false) : self
{
if ( null !== ( $pragma = $this->getFragment(Query\Sqlite\Pragma::class) ) ) {
$pragma->set($name, $value, $callable);
}
else {
$pragma = new Query\Sqlite\Pragma();
$pragma->set($name, $value, $callable);
$this->push($pragma);
}
return $this;
}
public function showColumns(string $table) : self
{
$this->pragma('table_info', $table, true);
return $this;
}
public function showTables(? string $database = null) : self
{
$show = new Query\Show();
$this->push($show);
$show->set(Query\Show::SQL_SHOW_TABLES, $database);
return $this;
}
public function insert(array $fieldlist, string $table, ? string $alias = null, ? string $database = null, ? string $schema = null, bool $replace = false) : self
{
return parent::insert($fieldlist, $table, $alias, null, null, $replace);
}
public function update(string $table, ? string $alias = null, ? string $database = null, ? string $schema = null) : self
{
return parent::update($table, $alias, null, null);
}
public function create(AdapterInterface $adapter, array $fieldlist, string $table, ? string $database = null, ? string $schema = null) : self
{
return parent::create($adapter, $fieldlist, $table, null, null);
}
public function alter(AdapterInterface $adapter, array $fieldlist, string $table, ? string $database = null, ? string $schema = null) : self
{
return parent::alter($adapter, $fieldlist, $table, null, null);
}
public function from(string $table, ? string $alias = null, ? string $database = null, ? string $schema = null) : self
{
return parent::from($table, $alias, null, null);
}
public function truncate(string $table, ? string $alias = null, ? string $database = null, ? string $schema = null) : self
{
$truncate = new Query\Sqlite\Truncate($this);
$this->push($truncate);
$truncate->set($table);
return $this;
}
}