diff --git a/vendor/model/Database.class.php b/vendor/model/Database.class.php index 75b4720..f0eab8c 100644 --- a/vendor/model/Database.class.php +++ b/vendor/model/Database.class.php @@ -128,21 +128,31 @@ class Database :last_modified, :db_accessible)'; - /** Preparo o sql para receber os valores */ - $this->stmt = $this->connection->connect()->prepare($this->sql); + try{ + /** Preparo o sql para receber os valores */ + $this->stmt = $this->connection->connect()->prepare($this->sql); + + /** Inicia a transação */ + $this->connection->connect()->beginTransaction(); - /** Inicia a transação */ - $this->connection->connect()->beginTransaction(); + /** Preencho os parâmetros do SQL */ + $this->stmt->bindParam(':client_id', $this->clientId); + $this->stmt->bindParam(':file_size', $this->fileSize); + $this->stmt->bindParam(':last_modified', $this->lastModified); + $this->stmt->bindParam(':db_accessible', $this->dbAccessible); - /** Preencho os parâmetros do SQL */ - $this->stmt->bindParam(':client_id', $this->clientId); - $this->stmt->bindParam(':file_size', $this->fileSize); - $this->stmt->bindParam(':last_modified', $this->lastModified); - $this->stmt->bindParam(':db_accessible', $this->dbAccessible); + /** Executo o SQL */ + $this->stmt->execute(); - /** Executo o SQL */ - $this->stmt->execute(); + } catch (\Exception $exception) { + + /** Desfaz a transação */ + $this->connection->connect()->rollback(); + + /** Informo */ + throw new InvalidArgumentException($exception->getMessage(), 0); + } } @@ -156,10 +166,11 @@ class Database $this->sql = 'delete from db where client_id = :client_id'; - /** Preparo o sql para receber os valores */ - $this->stmt = $this->connection->connect()->prepare($this->sql); - try { + try { + + /** Preparo o sql para receber os valores */ + $this->stmt = $this->connection->connect()->prepare($this->sql); /** Inicia a transação */ $this->connection->connect()->beginTransaction(); @@ -179,9 +190,8 @@ class Database /** Desfaz a transação */ $this->connection->connect()->rollback(); - /** Captura o erro */ - array_push($this->errors, 'Error:: ' . $exception->getMessage()); - return false; + /** Informo */ + throw new InvalidArgumentException($exception->getMessage(), 0); } }