Lexiconga/public/api/Db.php

27 lines
682 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();
}
public function errorInfo () {
return $this->dbh->errorInfo();
}
2017-12-24 20:00:45 +01:00
}