<?php
class DB_conncect
{
    private $con;
    function connectToDB(){
        include_once dirname(__FILE__) .'/constants.php';
        $this->con = new mysqli(DB_HOST, DB_USER_NAME, DB_PASSWORD, DB_NAME);
        if ($this->con->connect_errno) {  // check connection

            return "<script>console.log(".$this->con->connect_errno.")</script>";
        } else {

            return $this->con;
        }
    }
	
	 function connectToDBVia_PDO(){
        include_once dirname(__FILE__) .'/constants.php';
		  $servername = DB_HOST;
$username = DB_USER_NAME;
$password = DB_PASSWORD;
$dbname = DB_NAME;
  $this->con = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
  // set the PDO error mode to exception
  $this->con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
		 $status = $this->con->getAttribute(PDO::ATTR_CONNECTION_STATUS);
//		 echo $status;
		 return $this->con;
       
    }
}
?>
