From 7d2cca2de44e5c7d1de3e669294077cc6a619732 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 17 Mar 2021 14:34:44 +0100 Subject: Add missing changes --- install.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/install.php b/install.php index 1038b400..fa1258e0 100644 --- a/install.php +++ b/install.php @@ -48,13 +48,34 @@ define('UPDATE_FAILED', 'UPDATE_FAILED'); // Fatal error occurred, retry will no */ function tableHasColumn($table, $column) +{ + return tableColumnType($table, $column) !== false; +} + +/** + * Get type of column, as reported by DESCRIBE ; + */ +function tableColumnType($table, $column) +{ + return tableGetDescribeColumn($table, $column, 'Type'); +} + +function tableColumnKeyType($table, $column) +{ + return tableGetDescribeColumn($table, $column, 'Key'); +} + +/** + * For internal use + */ +function tableGetDescribeColumn($table, $column, $what) { $table = preg_replace('/\W/', '', $table); $res = Database::simpleQuery("DESCRIBE `$table`", array(), true); if ($res !== false) { while ($row = $res->fetch(PDO::FETCH_ASSOC)) { if ((is_array($column) && in_array($row['Field'], $column)) || (is_string($column) && $row['Field'] === $column)) - return true; + return $row[$what]; } } return false; -- cgit v1.2.3-55-g7522