Обработка constatint

This commit is contained in:
Фёдор Подлеснов 2018-02-07 13:42:03 +03:00
parent 080733b2eb
commit 5e1362d103

View file

@ -141,10 +141,20 @@ class Database_Manager
$this->db->query($q);
}
function getConstraintDef($c) {
if ($c['type'] == 'unique') {
return "UNIQUE(" . implode(", ", $c['fields']) . ")";
}
return "";
}
//CreateTableQuery('users',['id'=>['type'=>'integer','constraint'=>'PRIMARY KEY']])
public function CreateTableQuery($table, $fields, $constraints) {
$pg = $this->db->isPostgres();
if ($constraints) {
if (is_array($constraints)) {
$constraints = $this->getConstraintDef($constraints);
}
$constraints = ", " . $constraints;
}