DB Entities, SQL Update

This commit is contained in:
2022-06-17 20:53:35 +02:00
parent 6bbf517196
commit 6d600d4004
17 changed files with 443 additions and 70 deletions

View File

@@ -2,6 +2,11 @@
namespace Driver\SQL\Query;
use Driver\SQL\Column\BigIntColumn;
use Driver\SQL\Column\Column;
use Driver\SQL\Column\DoubleColumn;
use Driver\SQL\Column\FloatColumn;
use Driver\SQL\Column\NumericColumn;
use Driver\SQL\Column\SerialColumn;
use Driver\SQL\Column\StringColumn;
use Driver\SQL\Column\IntColumn;
@@ -10,6 +15,7 @@ use Driver\SQL\Column\EnumColumn;
use Driver\SQL\Column\BoolColumn;
use Driver\SQL\Column\JsonColumn;
use Driver\SQL\Constraint\Constraint;
use Driver\SQL\Constraint\PrimaryKey;
use Driver\SQL\Constraint\Unique;
use Driver\SQL\Constraint\ForeignKey;
@@ -31,6 +37,16 @@ class CreateTable extends Query {
$this->ifNotExists = false;
}
public function addColumn(Column $column): CreateTable {
$this->columns[$column->getName()] = $column;
return $this;
}
public function addConstraint(Constraint $constraint): CreateTable {
$this->constraints[] = $constraint;
return $this;
}
public function addSerial(string $name): CreateTable {
$this->columns[$name] = new SerialColumn($name);
return $this;
@@ -71,6 +87,21 @@ class CreateTable extends Query {
return $this;
}
public function addNumeric(string $name, bool $nullable = false, $defaultValue = NULL, ?int $digitsTotal = 10, ?int $digitsDecimal = 0): CreateTable {
$this->columns[$name] = new NumericColumn($name, $nullable, $defaultValue, $digitsTotal, $digitsDecimal);
return $this;
}
public function addFloat(string $name, bool $nullable = false, $defaultValue = NULL, ?int $digitsTotal = null, ?int $digitsDecimal = null): CreateTable {
$this->columns[$name] = new FloatColumn($name, $nullable, $defaultValue, $digitsTotal, $digitsDecimal);
return $this;
}
public function addDouble(string $name, bool $nullable = false, $defaultValue = NULL, ?int $digitsTotal = null, ?int $digitsDecimal = null): CreateTable {
$this->columns[$name] = new DoubleColumn($name, $nullable, $defaultValue, $digitsTotal, $digitsDecimal);
return $this;
}
public function primaryKey(...$names): CreateTable {
$this->constraints[] = new PrimaryKey($names);
return $this;