2017-12-24 20:00:45 +01:00
|
|
|
<?php
|
|
|
|
class Db {
|
|
|
|
private $dbh;
|
2017-12-24 22:19:42 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2017-12-24 22:19:42 +01:00
|
|
|
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
|
|
|
}
|