38 lines
884 B
PHP
38 lines
884 B
PHP
<?php
|
|
namespace ProVM\Ideal\Database\Query;
|
|
|
|
use ProVM\Ideal\Database\Query;
|
|
use ProVM\Concept\Database;
|
|
use ProVM\Reinforce\Database\Query\hasTable;
|
|
|
|
abstract class Drop extends Query implements Database\Query\Drop
|
|
{
|
|
use hasTable;
|
|
|
|
public function __construct(?string $table = null)
|
|
{
|
|
if ($table !== null) {
|
|
$this->table($table);
|
|
}
|
|
}
|
|
public function table(string $table): Database\Query\Drop
|
|
{
|
|
return $this->setTable($table);
|
|
}
|
|
public function cascade(): Database\Query\Drop
|
|
{
|
|
$this->cascade = true;
|
|
return $this;
|
|
}
|
|
|
|
protected bool $cascade = false;
|
|
protected function getCascadeString(): string
|
|
{
|
|
return $this->cascade ? ' CASCADE' : '';
|
|
}
|
|
public function build(): string
|
|
{
|
|
return "DROP TABLE {$this->getTable()}{$this->getCascadeString()}";
|
|
}
|
|
}
|