diff options
author | Simon Rettberg | 2021-03-17 14:34:44 +0100 |
---|---|---|
committer | Simon Rettberg | 2021-03-17 14:34:44 +0100 |
commit | 7d2cca2de44e5c7d1de3e669294077cc6a619732 (patch) | |
tree | 0544c36a3d9a10cd1fb3308b142c78a987b21e2c /install.php | |
parent | [rebootcontrol] Simplify some logic, improve scheduler (diff) | |
download | slx-admin-7d2cca2de44e5c7d1de3e669294077cc6a619732.tar.gz slx-admin-7d2cca2de44e5c7d1de3e669294077cc6a619732.tar.xz slx-admin-7d2cca2de44e5c7d1de3e669294077cc6a619732.zip |
Add missing changes
Diffstat (limited to 'install.php')
-rw-r--r-- | install.php | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/install.php b/install.php index 1038b400..fa1258e0 100644 --- a/install.php +++ b/install.php @@ -49,12 +49,33 @@ 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 <table>; + */ +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; |