diff --git a/src/Eloquent/Database.php b/src/Eloquent/Database.php index 41616d8..7e754f6 100644 --- a/src/Eloquent/Database.php +++ b/src/Eloquent/Database.php @@ -258,7 +258,11 @@ public function unprepared($query) { $result = $this->db->query($query); - return ($result === false || $this->db->last_error); + if ($result === false || $this->db->last_error) { + throw new QueryException($query, [], new \Exception($this->db->last_error)); + } + + return $result; } /** @@ -319,10 +323,8 @@ public function transaction(\Closure $callback) */ public function beginTransaction() { - $transaction = $this->unprepared("START TRANSACTION;"); - if ($transaction) { - $this->transactionCount++; - } + $this->unprepared("START TRANSACTION;"); + $this->transactionCount++; } /** @@ -335,10 +337,8 @@ public function commit() if ($this->transactionCount < 1) { return; } - $transaction = $this->unprepared("COMMIT;"); - if ($transaction) { - $this->transactionCount--; - } + $this->unprepared("COMMIT;"); + $this->transactionCount--; } /** @@ -351,10 +351,8 @@ public function rollBack() if ($this->transactionCount < 1) { return; } - $transaction = $this->unprepared("ROLLBACK;"); - if ($transaction) { - $this->transactionCount--; - } + $this->unprepared("ROLLBACK;"); + $this->transactionCount--; } /**