diff options
Diffstat (limited to 'classes/dbupdater.php')
-rw-r--r-- | classes/dbupdater.php | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/classes/dbupdater.php b/classes/dbupdater.php index c32afedee..94307aea0 100644 --- a/classes/dbupdater.php +++ b/classes/dbupdater.php @@ -42,15 +42,22 @@ class DbUpdater { foreach ($lines as $line) { if (strpos($line, "--") !== 0 && $line) { - if (!$this->pdo->query($line)) { + + if ($html_output) + print "<pre>$line</pre>"; + else + Debug::log("> $line"); + + try { + $this->pdo->query($line); // PDO returns errors as exceptions now + } catch (PDOException $e) { if ($html_output) { - print_notice("Query: $line"); - print_error("Error: " . implode(", ", $this->pdo->errorInfo())); + print "<div class='text-error'>Error: " . $e->getMessage() . "</div>"; } else { - Debug::log("Query: $line"); - Debug::log("Error: " . implode(", ", $this->pdo->errorInfo())); + Debug::log("Error: " . $e->getMessage()); } + $this->pdo->rollBack(); return false; } } @@ -73,4 +80,4 @@ class DbUpdater { } } -}
\ No newline at end of file +} |