Database abstraction
This commit is contained in:
16
core/Driver/SQL/Constraint/Constraint.class.php
Normal file
16
core/Driver/SQL/Constraint/Constraint.class.php
Normal 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; }
|
||||
};
|
||||
|
||||
?>
|
||||
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 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; }
|
||||
};
|
||||
|
||||
?>
|
||||
13
core/Driver/SQL/Constraint/PrimaryKey.class.php
Normal file
13
core/Driver/SQL/Constraint/PrimaryKey.class.php
Normal 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);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
?>
|
||||
13
core/Driver/SQL/Constraint/Unique.class.php
Normal file
13
core/Driver/SQL/Constraint/Unique.class.php
Normal 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);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user