transactions

front-page-background
Shish 2 years ago
parent a4ff796b35
commit 81fe37de50
  1. 8
      core/install.php
  2. 4
      index.php

@ -281,14 +281,18 @@ function create_tables(Database $db)
$db->execute("CREATE INDEX images_tags_tag_id_idx ON image_tags(tag_id)", []);
$db->execute("INSERT INTO config(name, value) VALUES('db_version', 11)");
$db->commit();
// mysql auto-commits when creating a table, so the transaction
// is closed; other databases need to commit
if($db->is_transaction_open()) {
$db->commit();
}
} catch (PDOException $e) {
throw new InstallerException(
"PDO Error:",
"<p>An error occurred while trying to create the database tables necessary for Shimmie.</p>
<p>Please check and ensure that the database configuration options are all correct.</p>
<p>{$e->getMessage()}</p>
<!-- {$e->getTraceAsString()} -->
",
3
);

@ -83,7 +83,7 @@ try {
$page->display();
}
if ($database->transaction===true) {
if ($database->is_transaction_open()) {
$database->commit();
}
@ -92,7 +92,7 @@ try {
fastcgi_finish_request();
}
} catch (Exception $e) {
if ($database && $database->transaction===true) {
if ($database && $database->is_transaction_open()) {
$database->rollback();
}
_fatal_error($e);

Loading…
Cancel
Save