Created
March 25, 2017 17:21
-
-
Save Deviad/f6a4b87ccdcb1de48ad8ab9a7e6c2a56 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 | |
namespace App\Db; | |
class DbMgmt | |
{ | |
const SERVERNAME = 'localhost'; | |
const PORT = "3306"; | |
const USERNAME = 'root'; | |
const PASSWORD = ''; | |
const DBNAME = 'universumphp'; | |
const CHARSET = 'utf8'; | |
public $conn; | |
// private static $instance = false; | |
public function __constructor() { | |
$this->newConn(); | |
} | |
public function newConn() | |
{ | |
try { | |
$this->conn = new \PDO('mysql:host=' . self::SERVERNAME . ";port=" . self::PORT . ";dbname=" . self::DBNAME . ";charset=" . self::CHARSET, self::USERNAME, self::PASSWORD); | |
$this->conn->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); | |
// echo "Connection established <br>"; | |
} catch (\PDOException $e) { | |
echo $e->getMessage(); | |
} | |
return $this->conn; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment