-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdb.class.php
More file actions
28 lines (23 loc) · 808 Bytes
/
db.class.php
File metadata and controls
28 lines (23 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
class Db{
private $servername = "localhost";
private $username = "root";
private $password = "";
private $dbname = "mega_menu";
private $conn;
public function __construct(){
try {
$this->conn = new PDO("mysql:host=".$this->servername.";dbname=".$this->dbname, $this->username, $this->password);
$this->conn->setAttribute(
PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION
);
} catch (PDOException $e) {
echo "Connection Failed :" .$e->getMessage();
}
}
public function query($query){
$stmt = $this->conn->prepare($query);
$stmt->execute();
return $stmt->fetchAll();
}
}