Skip to content

Commit bd3ff7e

Browse files
committed
CHANGE: try catch
1 parent 29fd9e4 commit bd3ff7e

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

lib/PHPDO.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,13 @@ public function getLastQuery() {
120120
* @return PDOStatement
121121
*/
122122
public function query(string $query) {
123-
$queryObj = $this->PDO->query($query);
123+
124+
try {
125+
$queryObj = $this->PDO->query($query);
126+
}
127+
catch (\Exception $e) {
128+
die($e->getCode() . ": " . $e->getMessage());
129+
}
124130

125131
$this->addLog($query, gettype($queryObj));
126132

@@ -138,8 +144,14 @@ public function query(string $query) {
138144
* @return PDOStatement
139145
*/
140146
public function prepare(string $query, array $mapping) : PDOStatement {
141-
$pdoStmnt = $this->PDO->prepare($query);
142-
$execute = $pdoStmnt->execute($mapping);
147+
148+
try {
149+
$pdoStmnt = $this->PDO->prepare($query);
150+
$execute = $pdoStmnt->execute($mapping);
151+
}
152+
catch (\Exception $e) {
153+
die($e->getCode() . ": " . $e->getMessage());
154+
}
143155

144156
$this->addLog($pdoStmnt->queryString, $execute);
145157

@@ -154,7 +166,13 @@ public function prepare(string $query, array $mapping) : PDOStatement {
154166
* @return int
155167
*/
156168
public function execute(string $query) : int {
157-
$exec = $this->PDO->exec($query);
169+
170+
try {
171+
$exec = $this->PDO->exec($query);
172+
}
173+
catch (\Exception $e) {
174+
die($e->getCode() . ": " . $e->getMessage());
175+
}
158176

159177
$this->addLog($query, $exec);
160178

0 commit comments

Comments
 (0)