diff --git a/src/Database/Adapter/MariaDB.php b/src/Database/Adapter/MariaDB.php index 1e176b0c1..6e51947f4 100644 --- a/src/Database/Adapter/MariaDB.php +++ b/src/Database/Adapter/MariaDB.php @@ -654,7 +654,11 @@ public function createDocument(string $collection, Document $document): Document $columns = ''; $columnNames = ''; - $this->getPDO()->beginTransaction(); + try { + $this->getPDO()->beginTransaction(); + } catch (PDOException $e) { + $this->getPDO()->rollBack(); + } /** * Insert Attributes @@ -798,7 +802,11 @@ public function updateDocument(string $collection, Document $document): Document return $carry; }, $initial); - $this->getPDO()->beginTransaction(); + try { + $this->getPDO()->beginTransaction(); + } catch (PDOException $e) { + $this->getPDO()->rollBack(); + } /** * Get removed Permissions @@ -1005,7 +1013,11 @@ public function deleteDocument(string $collection, string $id): bool { $name = $this->filter($collection); - $this->getPDO()->beginTransaction(); + try { + $this->getPDO()->beginTransaction(); + } catch (PDOException $e) { + $this->getPDO()->rollBack(); + } $sql = " DELETE FROM {$this->getSQLTable($name)} diff --git a/src/Database/Adapter/SQLite.php b/src/Database/Adapter/SQLite.php index f50c66815..c30980465 100644 --- a/src/Database/Adapter/SQLite.php +++ b/src/Database/Adapter/SQLite.php @@ -110,7 +110,11 @@ public function createCollection(string $name, array $attributes = [], array $in $namespace = $this->getNamespace(); $id = $this->filter($name); - $this->getPDO()->beginTransaction(); + try { + $this->getPDO()->beginTransaction(); + } catch (PDOException $e) { + $this->getPDO()->rollBack(); + } /** @var array $attributeStrings */ $attributeStrings = []; @@ -228,7 +232,11 @@ public function deleteCollection(string $id): bool { $id = $this->filter($id); - $this->getPDO()->beginTransaction(); + try { + $this->getPDO()->beginTransaction(); + } catch (PDOException $e) { + $this->getPDO()->rollBack(); + } $sql = "DROP TABLE `{$this->getNamespace()}_{$id}`"; $sql = $this->trigger(Database::EVENT_COLLECTION_DELETE, $sql); @@ -424,7 +432,11 @@ public function createDocument(string $collection, Document $document): Document $columns = ['_uid']; $values = ['_uid']; - $this->getPDO()->beginTransaction(); + try { + $this->getPDO()->beginTransaction(); + } catch (PDOException $e) { + $this->getPDO()->rollBack(); + } /** * Insert Attributes @@ -567,7 +579,11 @@ public function updateDocument(string $collection, Document $document): Document return $carry; }, $initial); - $this->getPDO()->beginTransaction(); + try { + $this->getPDO()->beginTransaction(); + } catch (PDOException $e) { + $this->getPDO()->rollBack(); + } /** * Get removed Permissions