From 2716fe0432aceb653c3454282823aeba7a56c9d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Sun, 4 May 2014 00:33:49 +0200 Subject: [PATCH] fixed database migration method --- application/core/Database/MigrationHelper.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/application/core/Database/MigrationHelper.php b/application/core/Database/MigrationHelper.php index a6025bdc..3ed3088f 100644 --- a/application/core/Database/MigrationHelper.php +++ b/application/core/Database/MigrationHelper.php @@ -40,20 +40,23 @@ class MigrationHelper { $mysqli = $this->maniaControl->database->mysqli; - $query = "INSERT INTO `" . SettingManager::TABLE_SETTINGS . "` (`class`, `setting`, `type`, `value`, `default`) - SELECT ?, `setting`, `type`, `value`, `default` FROM `" . SettingManager::TABLE_SETTINGS . "` WHERE `class` = ?;"; + $query = "INSERT IGNORE INTO `" . SettingManager::TABLE_SETTINGS . "` + (`class`, `setting`, `type`, `value`, `default`) + SELECT ?, `setting`, `type`, `value`, `default` + FROM `" . SettingManager::TABLE_SETTINGS . "` + WHERE `class` = ?;"; $statement = $mysqli->prepare($query); if ($mysqli->error) { trigger_error($mysqli->error); return false; } $statement->bind_param('ss', $targetClass, $sourceClass); + $success = $statement->execute(); if ($statement->error) { trigger_error($statement->error); $statement->close(); return false; } - $success = $statement->execute(); $statement->close(); return $success; }