<?php
ob_start();

defined('server') ? null : define("server", "localhost");
defined('user') ? null : define ("user", "root") ;
defined('pass') ? null : define("pass","");
defined('database_name') ? null : define("database_name", "engb") ;

$this_file = str_replace('\\', '/', __File__) ;
$doc_root = $_SERVER['DOCUMENT_ROOT'];

$web_root =  str_replace (array($doc_root, "var/controller.php") , '' , $this_file);
$server_root = str_replace ('var/controller.php' ,'', $this_file);


define ('web_root' , $web_root);
define('server_root' , $server_root);

date_default_timezone_set('Africa/Kigali');
// DB credentials.
define('DB_HOST','localhost');
define('DB_USER','root');
define('DB_PASS','');
define('DB_NAME','engb');
// Establish database connection.

try
{
$dbh = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME,DB_USER, DB_PASS,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));
}
catch (PDOException $e)
{
exit("Error: " . $e->getMessage());
}


//PDO Connection 
$db = new PDO('mysql:host=localhost;dbname=engb;charset=utf8', 'root','');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->query('SET SESSION SQL_BIG_SELECTS=1');

//2and PDO CONNECTION

$db_username = 'root';
$db_password = '';
$conn = new PDO( 'mysql:host=localhost;dbname=engb', $db_username, $db_password );
if(!$conn){
	die("Fatal Error: Connection Failed!");
}
	
	
ob_end_flush();
?>

