Skip to content

Commit b7d44e8

Browse files
committed
Exception wenn Statement nicht ausgeführt werden kann
1 parent 8c329b5 commit b7d44e8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Kir/MySQL/Databases/MySQL.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?php
22
namespace Kir\MySQL\Databases;
33

4-
use Kir\MySQL\Builder;
5-
use Kir\MySQL\Database;
64
use PDO;
5+
use Exception;
76
use PDOStatement;
8-
use Kir\MySQL\Builder\RunnableSelect;
7+
use Kir\MySQL\Builder;
8+
use Kir\MySQL\Database;
99
use UnexpectedValueException;
10+
use Kir\MySQL\Builder\RunnableSelect;
1011

1112
class MySQL implements Database {
1213
/**
@@ -28,10 +29,14 @@ public function __construct(PDO $pdo) {
2829

2930
/**
3031
* @param string $query
32+
* @throws Exception
3133
* @return PDOStatement
3234
*/
3335
public function query($query) {
3436
$stmt = $this->pdo->query($query);
37+
if(!$stmt) {
38+
throw new Exception("Could not execute statement:\n{$query}");
39+
}
3540
$stmt->execute();
3641
return $stmt;
3742
}

0 commit comments

Comments
 (0)