<?php
$dsn = require '.dbconfig.inc.php';
-$options = [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ];
-$Db = new PDO($dsn, NULL, NULL, $options);
+$Db = new DB($dsn);
+
+class DB
+{
+ public $dbh;
+
+ function __construct($config, $options = [])
+ {
+ $options += [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ];
+ $this->dbh = new PDO($config, NULL, NULL, $options);
+ }
+
+ function query($sql, $params = [])
+ {
+ $stmt = $this->dbh->prepare($sql);
+ $stmt->execute($params);
+ return $stmt;
+ }
+}