diff options
author | Andrew Dolgov <[email protected]> | 2019-03-06 19:05:44 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2019-03-06 19:05:44 +0300 |
commit | 26c226c8e44cd1f817aad191b4937aaa7b5674b1 (patch) | |
tree | 3a3468ac1e4e7c7cb2da095b17264bcea4339a37 /classes/dbupdater.php | |
parent | 684a1368e9794abfb5c70877304dcf06110ca1d7 (diff) |
dbupdater: catch PDO exception instead of internal errors since we're using those now; log queries while updating
Diffstat (limited to 'classes/dbupdater.php')
-rw-r--r-- | classes/dbupdater.php | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/classes/dbupdater.php b/classes/dbupdater.php index c32afedee..9b01f2156 100644 --- a/classes/dbupdater.php +++ b/classes/dbupdater.php @@ -41,13 +41,19 @@ class DbUpdater { $this->pdo->beginTransaction(); foreach ($lines as $line) { + + if ($html_output) + print "<pre>$line</pre>"; + else + print "\t$line\n"; + if (strpos($line, "--") !== 0 && $line) { - if (!$this->pdo->query($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())); } else { - Debug::log("Query: $line"); Debug::log("Error: " . implode(", ", $this->pdo->errorInfo())); } @@ -73,4 +79,4 @@ class DbUpdater { } } -}
\ No newline at end of file +} |