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:
Visman 2021-12-20 20:08:55 +07:00
parent 5b5fedde23
commit cd975a3855

View file

@ -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;
}