Skip to content

Instantly share code, notes, and snippets.

@Deviad
Created March 25, 2017 17:21
Show Gist options
  • Save Deviad/d515c155a44fe2d36e2ad84315aa6a89 to your computer and use it in GitHub Desktop.
Save Deviad/d515c155a44fe2d36e2ad84315aa6a89 to your computer and use it in GitHub Desktop.
<?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