diff --git a/wa-system/database/waDbMysqliAdapter.class.php b/wa-system/database/waDbMysqliAdapter.class.php index 8856d0128..318ccb32f 100644 --- a/wa-system/database/waDbMysqliAdapter.class.php +++ b/wa-system/database/waDbMysqliAdapter.class.php @@ -190,7 +190,11 @@ public function errorCode() */ public function schema($table, $keys = false) { - $res = $this->query("DESCRIBE ".$table); + try { + $res = $this->query("SHOW FULL COLUMNS FROM " . $table); + } catch (waDbException) { + $res = $this->query("DESCRIBE " . $table); + } if (!$res) { $this->exception(); } @@ -215,6 +219,10 @@ public function schema($table, $keys = false) $field['default'] = $row['Default']; } + if (!empty($row['Comment'])) { + $field['comment'] = $row['Comment']; + } + if ($row['Extra'] == 'auto_increment') { $field['autoincrement'] = 1; } @@ -435,6 +443,9 @@ protected function buildStatements($data) if (!empty($field['autoincrement'])) { $type .= ' AUTO_INCREMENT'; } + if (!empty($field['comment'])) { + $type .= " COMMENT '" . $this->escape($field['comment']) . "'"; + } $fields[$field_id] = $this->escapeField($field_id)." ".$type; } }