Namespace and ClassPath rewrites
This commit is contained in:
18
Core/Driver/SQL/Constraint/Constraint.class.php
Normal file
18
Core/Driver/SQL/Constraint/Constraint.class.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Core\Driver\SQL\Constraint;
|
||||
|
||||
abstract class Constraint {
|
||||
|
||||
private array $columnNames;
|
||||
private ?string $name;
|
||||
|
||||
public function __construct($columnNames, ?string $constraintName = NULL) {
|
||||
$this->columnNames = (!is_array($columnNames) ? array($columnNames) : $columnNames);
|
||||
$this->name = $constraintName;
|
||||
}
|
||||
|
||||
public function getColumnNames(): array { return $this->columnNames; }
|
||||
public function getName(): ?string { return $this->name; }
|
||||
public function setName(string $name) { $this->name = $name; }
|
||||
}
|
||||
23
Core/Driver/SQL/Constraint/ForeignKey.class.php
Normal file
23
Core/Driver/SQL/Constraint/ForeignKey.class.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Core\Driver\SQL\Constraint;
|
||||
|
||||
use Core\Driver\SQL\Strategy\Strategy;
|
||||
|
||||
class ForeignKey extends Constraint {
|
||||
|
||||
private string $referencedTable;
|
||||
private string $referencedColumn;
|
||||
private ?Strategy $strategy;
|
||||
|
||||
public function __construct(string $columnName, string $refTable, string $refColumn, ?Strategy $strategy = NULL) {
|
||||
parent::__construct($columnName);
|
||||
$this->referencedTable = $refTable;
|
||||
$this->referencedColumn = $refColumn;
|
||||
$this->strategy = $strategy;
|
||||
}
|
||||
|
||||
public function getReferencedTable(): string { return $this->referencedTable; }
|
||||
public function getReferencedColumn(): string { return $this->referencedColumn; }
|
||||
public function onDelete(): ?Strategy { return $this->strategy; }
|
||||
}
|
||||
11
Core/Driver/SQL/Constraint/PrimaryKey.class.php
Normal file
11
Core/Driver/SQL/Constraint/PrimaryKey.class.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Core\Driver\SQL\Constraint;
|
||||
|
||||
class PrimaryKey extends Constraint {
|
||||
|
||||
public function __construct(...$names) {
|
||||
parent::__construct((!empty($names) && is_array($names[0])) ? $names[0] : $names);
|
||||
}
|
||||
|
||||
}
|
||||
11
Core/Driver/SQL/Constraint/Unique.class.php
Normal file
11
Core/Driver/SQL/Constraint/Unique.class.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Core\Driver\SQL\Constraint;
|
||||
|
||||
class Unique extends Constraint {
|
||||
|
||||
public function __construct(...$names) {
|
||||
parent::__construct((!empty($names) && is_array($names[0])) ? $names[0] : $names);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user