diff options
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; |