2 $dsn = require '.dbconfig.inc.php';
9 function __construct($config, $options = [])
12 PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
13 PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ,
15 $this->dbh = new PDO($config, NULL, NULL, $options);
18 function query($sql, $params = [])
20 $stmt = $this->dbh->prepare($sql);
21 $stmt->execute($params);
25 function insert($table, $row)
27 $sql = sprintf('INSERT INTO %s (%s) VALUES (%s)',
29 implode(', ', array_keys($row)),
30 implode(', ', array_fill(0, count($row), '?'))
32 return $this->query($sql, array_values($row));