-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.php
More file actions
27 lines (25 loc) · 817 Bytes
/
database.php
File metadata and controls
27 lines (25 loc) · 817 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
<?php
class Database {
//Created by Aaron C. 09/19/2024 Finished 09/20/2024
// will need database info to assign variables
private $dbName = "";
private $user = "";
private $password = "";
private $host = "";
public $conn;
public function getConnection(){
$this -> conn = null;
try{
$this -> conn = new PDO("mysql:host=" . $this -> host . ";dbname=" . $this -> dbName, $this -> user, $this -> password);
$this -> conn -> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $exception){
echo "Connection error: " . $exception -> getMessage();
}
return $this -> conn;
}
public function closeDB(){
$this -> conn = null;
}
}
?>