From bb30a69932a26ef3418801bd70ad75592e7e2e23 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Mon, 14 Apr 2014 11:05:37 +0200 Subject: [PATCH] Fixed (again !) execute --- core/lib/Thelia/Install/Database.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Install/Database.php b/core/lib/Thelia/Install/Database.php index 826e392a0..e09ea3b4b 100644 --- a/core/lib/Thelia/Install/Database.php +++ b/core/lib/Thelia/Install/Database.php @@ -108,10 +108,21 @@ class Database * * @param string $sql SQL query * @param array $args SQL request parameters (PDO style) + * @throws \RuntimeException|\PDOException if something goes wrong. */ public function execute($sql, $args = array()) { - $this->connection->query($sql, $args); + $stmt = $this->connection->prepare($sql); + + if ($stmt === false) { + throw new \RuntimeException("Failed to prepare statement for $sql: " . print_r($this->connection->errorInfo(), 1)); + } + + $success = $stmt->execute($args); + + if ($success === false || $stmt->errorCode() != 0) { + throw new \RuntimeException("Failed to execute SQL '$sql', arguments:" . print_r($args,1).", error:".print_r($stmt->errorInfo(), 1)); + } } /**