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,13 @@
<?php
namespace Driver\SQL\Column;
class BoolColumn extends Column {
public function __construct($name, $defaultValue=false) {
parent::__construct($name, false, $defaultValue);
}
}
?>

View File

@@ -0,0 +1,23 @@
<?php
namespace Driver\SQL\Column;
class Column {
private $name;
private $nullable;
private $defaultValue;
public function __construct($name, $nullable = false, $defaultValue = NULL) {
$this->name = $name;
$this->nullable = $nullable;
$this->defaultValue = $defaultValue;
}
public function getName() { return $this->name; }
public function notNull() { return !$this->nullable; }
public function getDefaultValue() { return $this->defaultValue; }
}
?>

View File

@@ -0,0 +1,12 @@
<?php
namespace Driver\SQL\Column;
class DateTimeColumn extends Column {
public function __construct($name, $nullable=false, $defaultValue=NULL) {
parent::__construct($name, $nullable, $defaultValue);
}
}
?>

View File

@@ -0,0 +1,17 @@
<?php
namespace Driver\SQL\Column;
class EnumColumn extends Column {
private $values;
public function __construct($name, $values, $nullable=false, $defaultValue=NULL) {
parent::__construct($name, $nullable, $defaultValue);
$this->values = $values;
}
public function getValues() { return $this->values; }
}
?>

View File

@@ -0,0 +1,13 @@
<?php
namespace Driver\SQL\Column;
class IntColumn extends Column {
public function __construct($name, $nullable=false, $defaultValue=NULL) {
parent::__construct($name, $nullable, $defaultValue);
}
}
?>

View File

@@ -0,0 +1,13 @@
<?php
namespace Driver\SQL\Column;
class JsonColumn extends Column {
public function __construct($name, $nullable=false, $defaultValue=null) {
parent::__construct($name, $nullable, $defaultValue);
}
}
?>

View File

@@ -0,0 +1,13 @@
<?php
namespace Driver\SQL\Column;
class SerialColumn extends Column {
public function __construct($name, $defaultValue=NULL) {
parent::__construct($name, false, $defaultValue); # not nullable
}
}
?>

View File

@@ -0,0 +1,17 @@
<?php
namespace Driver\SQL\Column;
class StringColumn extends Column {
private $maxSize;
public function __construct($name, $maxSize=null, $nullable=false, $defaultValue=null) {
parent::__construct($name, $nullable, $defaultValue);
$this->maxSize = $maxSize;
}
public function getMaxSize() { return $this->maxSize; }
}
?>