Some fixes / improvements
This commit is contained in:
@@ -4,13 +4,11 @@ namespace Driver\SQL\Constraint;
|
||||
|
||||
abstract class Constraint {
|
||||
|
||||
private $columnName;
|
||||
private array $columnNames;
|
||||
|
||||
public function __construct($columnName) {
|
||||
$this->columnName = $columnName;
|
||||
public function __construct($columnNames) {
|
||||
$this->columnNames = (!is_array($columnNames) ? array($columnNames) : $columnNames);
|
||||
}
|
||||
|
||||
public function getColumnName() { return $this->columnName; }
|
||||
};
|
||||
|
||||
?>
|
||||
public function getColumnNames() { return $this->columnNames; }
|
||||
}
|
||||
@@ -2,11 +2,13 @@
|
||||
|
||||
namespace Driver\SQL\Constraint;
|
||||
|
||||
use Driver\SQL\Strategy\Strategy;
|
||||
|
||||
class ForeignKey extends Constraint {
|
||||
|
||||
private $referencedTable;
|
||||
private $referencedColumn;
|
||||
private $strategy;
|
||||
private string $referencedTable;
|
||||
private string $referencedColumn;
|
||||
private ?Strategy $strategy;
|
||||
|
||||
public function __construct($name, $refTable, $refColumn, $strategy = NULL) {
|
||||
parent::__construct($name);
|
||||
@@ -18,6 +20,4 @@ class ForeignKey extends Constraint {
|
||||
public function getReferencedTable() { return $this->referencedTable; }
|
||||
public function getReferencedColumn() { return $this->referencedColumn; }
|
||||
public function onDelete() { return $this->strategy; }
|
||||
};
|
||||
|
||||
?>
|
||||
}
|
||||
@@ -8,6 +8,4 @@ class PrimaryKey extends Constraint {
|
||||
parent::__construct((!empty($names) && is_array($names[0])) ? $names[0] : $names);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
?>
|
||||
}
|
||||
|
||||
@@ -8,6 +8,4 @@ class Unique extends Constraint {
|
||||
parent::__construct((!empty($names) && is_array($names[0])) ? $names[0] : $names);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
?>
|
||||
}
|
||||
Reference in New Issue
Block a user