Fix DB\Mysql
Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
This commit is contained in:
parent
5b5fedde23
commit
cd975a3855
1 changed files with 8 additions and 8 deletions
|
@ -136,14 +136,6 @@ class Mysql
|
|||
$this->nameCheck($name);
|
||||
// имя и тип
|
||||
$query = '`' . $name . '` ' . $this->replType($data[0]);
|
||||
// не NULL
|
||||
if (empty($data[1])) {
|
||||
$query .= ' NOT NULL';
|
||||
}
|
||||
// значение по умолчанию
|
||||
if (isset($data[2])) {
|
||||
$query .= ' DEFAULT ' . $this->convToStr($data[2]);
|
||||
}
|
||||
// сравнение
|
||||
if (\preg_match('%^(?:CHAR|VARCHAR|TINYTEXT|TEXT|MEDIUMTEXT|LONGTEXT|ENUM|SET)\b%i', $data[0])) {
|
||||
$query .= ' CHARACTER SET utf8mb4 COLLATE utf8mb4_';
|
||||
|
@ -159,6 +151,14 @@ class Mysql
|
|||
$query .= 'unicode_ci';
|
||||
}
|
||||
}
|
||||
// не NULL
|
||||
if (empty($data[1])) {
|
||||
$query .= ' NOT NULL';
|
||||
}
|
||||
// значение по умолчанию
|
||||
if (isset($data[2])) {
|
||||
$query .= ' DEFAULT ' . $this->convToStr($data[2]);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue