diff options
author | Simon Rettberg | 2016-06-08 18:33:30 +0200 |
---|---|---|
committer | Simon Rettberg | 2016-06-08 18:33:30 +0200 |
commit | ffffab643e031524b6fdfe0c39adae1f6c8e9c4d (patch) | |
tree | 84e55c5a7ea0e02481b9f44730814ae788f05e12 /install.php | |
parent | [dashboard] Remove needsSchemaUpdate call (diff) | |
download | slx-admin-ffffab643e031524b6fdfe0c39adae1f6c8e9c4d.tar.gz slx-admin-ffffab643e031524b6fdfe0c39adae1f6c8e9c4d.tar.xz slx-admin-ffffab643e031524b6fdfe0c39adae1f6c8e9c4d.zip |
[install] Implement install scripts for most modules
Diffstat (limited to 'install.php')
-rw-r--r-- | install.php | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/install.php b/install.php index e579dd52..f3469abc 100644 --- a/install.php +++ b/install.php @@ -33,7 +33,7 @@ function finalResponse($status, $message = '') echo json_encode(array('status' => $status, 'message' => $message)); } else { echo 'STATUS=', $status, "\n"; - echo 'MESSAGE=', $message; + echo 'MESSAGE=', str_replace("\n", " -- ", $message); } exit; } @@ -77,13 +77,28 @@ function tableDropColumn($table, $column) function tableExists($table) { $res = Database::simpleQuery("SHOW TABLES", array(), true); - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { - if ($row['Tables_in_openslx'] === $table) + while ($row = $res->fetch(PDO::FETCH_NUM)) { + if ($row[0] === $table) return true; } return false; } +function tableCreate($table, $structure, $fatalOnError = true) +{ + if (tableExists($table)) { + return UPDATE_NOOP; + } + $ret = Database::exec("CREATE TABLE IF NOT EXISTS `{$table}` ( {$structure} ) ENGINE=InnoDB DEFAULT CHARSET=utf8"); + if ($ret !== false) { + return UPDATE_DONE; + } + if ($fatalOnError) { + finalResponse(UPDATE_FAILED, 'DB-Error: ' . Database::lastError()); + } + return UPDATE_FAILED; +} + /* * Rest of install script.... */ @@ -230,7 +245,7 @@ HERE; echo <<<HERE </table> <br><br> - <button onclick="slxRunInstall()">Install/Upgrade</button> + <button onclick="slxRunInstall(this)">Install/Upgrade</button> <script src="script/jquery.js"></script> <script src="script/install.js"></script> </body> |