first work on feed updater + pinger
[stapibas.git] / src / stapibas / PDO.php
diff --git a/src/stapibas/PDO.php b/src/stapibas/PDO.php
new file mode 100644 (file)
index 0000000..a85008b
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+namespace stapibas;
+
+/**
+ * Small error-handling wrapper around PDO
+ */
+class PDO extends \PDO
+{
+    public function query()
+    {
+        $args = func_get_args();
+        $res = call_user_func_array(array('parent', 'query'), $args);
+        if ($res !== false) {
+            return $res;
+        }
+
+        $this->handleError();
+    }
+
+    protected function handleError()
+    {
+        echo "SQL error\n";
+        echo " " . $this->errorCode() . "\n";
+        echo " " . implode(' - ', $this->errorInfo()) . "\n";
+    }
+}
+
+?>
\ No newline at end of file