-
-
Save anonymous/4031bbc7ce368d02df999a4faca4a293 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Database | |
{ | |
// specify your own database credentials | |
private $host = "localhost"; | |
private $db_name = "obiezaca_db"; | |
private $username = "root"; | |
private $password = ""; | |
public $conn; | |
// get the database connection | |
public function getConnection() | |
{ | |
$this->conn = null; | |
try | |
{ | |
$this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password); | |
$this->conn->exec("set names utf8"); | |
} | |
catch(PDOException $exception) | |
{ | |
echo "Connection error: " . $exception->getMessage(); | |
} | |
return $this->conn; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment