Database abstraction

This commit is contained in:
2020-04-02 00:02:51 +02:00
parent 26d28377be
commit 81995b06b8
51 changed files with 1660 additions and 641 deletions

View File

@@ -0,0 +1,16 @@
<?php
namespace Driver\SQL\Constraint;
abstract class Constraint {
private $columnName;
public function __construct($columnName) {
$this->columnName = $columnName;
}
public function getColumnName() { return $this->columnName; }
};
?>

View File

@@ -0,0 +1,23 @@
<?php
namespace Driver\SQL\Constraint;
class ForeignKey extends Constraint {
private $referencedTable;
private $referencedColumn;
private $strategy;
public function __construct($name, $refTable, $refColumn, $strategy = NULL) {
parent::__construct($name);
$this->referencedTable = $refTable;
$this->referencedColumn = $refColumn;
$this->strategy = $strategy;
}
public function getReferencedTable() { return $this->referencedTable; }
public function getReferencedColumn() { return $this->referencedColumn; }
public function onDelete() { return $this->strategy; }
};
?>

View File

@@ -0,0 +1,13 @@
<?php
namespace Driver\SQL\Constraint;
class PrimaryKey extends Constraint {
public function __construct(...$names) {
parent::__construct((!empty($names) && is_array($names[0])) ? $names[0] : $names);
}
};
?>

View File

@@ -0,0 +1,13 @@
<?php
namespace Driver\SQL\Constraint;
class Unique extends Constraint {
public function __construct(...$names) {
parent::__construct((!empty($names) && is_array($names[0])) ? $names[0] : $names);
}
};
?>