Обработка constatint
This commit is contained in:
parent
080733b2eb
commit
5e1362d103
1 changed files with 10 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue