Lexiconga/backend/Db.php

23 lines
608 B
PHP
Raw Normal View History

2017-12-24 20:00:45 +01:00
<?php
class Db {
private $dbh;
function __construct() {
2017-12-24 20:00:45 +01:00
$this->dbh = new PDO('mysql:host=localhost;dbname=lexiconga;charset=utf8', 'root', 'password');
$this->dbh->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
}
public function execute ($query, $params = array()) {
$stmt = $this->dbh->prepare($query);
return $stmt->execute($params);
}
2017-12-24 20:00:45 +01:00
public function query ($query, $params = array()) {
$stmt = $this->dbh->prepare($query);
$stmt->execute($params);
return $stmt;
}
2017-12-24 21:09:05 +01:00
public function lastInsertId () {
return $this->dbh->lastInsertId();
}
2017-12-24 20:00:45 +01:00
}