nieuws/replies: database class with query method
[minimedit.git] / database.inc.php
1 <?php
2 $dsn = require '.dbconfig.inc.php';
3 $Db = new DB($dsn);
4
5 class DB
6 {
7         public $dbh;
8
9         function __construct($config, $options = [])
10         {
11                 $options += [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ];
12                 $this->dbh = new PDO($config, NULL, NULL, $options);
13         }
14
15         function query($sql, $params = [])
16         {
17                 $stmt = $this->dbh->prepare($sql);
18                 $stmt->execute($params);
19                 return $stmt;
20         }
21 }