<?php

class db{
  	private $hostname;			// host serving db
	private $dbname;			// name of db
	private $uname;				// username we connect with
	private $pwd;				// password we connect with
	private $port;				// port we find server on
	private $db;				// database instance
  function __construct(){
  
  	$this->hostname = "localhost"; 
	$this->dbname = "medsysmagic";
	$this->uname = "root";
	$this->pwd = "autocad1";
	$this->port = 3306;
		
  	$this->db = new mysqli($this->hostname, $this->uname, $this->pwd, $this->dbname);
  	
  	if(mysqli_connect_errno()){
  		printf("Connect Failed: %s\n",mysqli_connect_errno());
  		exit();
  	}else {
  		//printf("Connect to db Webonly DB");
  	}
  	
  		/*if($this->db->connect_errno){
			throw new eDBException.php($this->db->connect_error);
			}
		*/
  }
 
  public function dbQuery($sql){

		$res = $this->db->query($sql);
		if($this->db->errno){
			echo $this->db->error;
			//throw new eDBException($this->db->error. " SQL [".$sql."]");
		} else {
			return $res;
		}
	}

/*
function mysqli_clean_connection() {
	$dbc= $this->db;
		     while( mysqli_more_results($dbc) ){
		        if(mysqli_next_result($dbc)){
		            $result = mysqli_use_result($dbc);
		            if( get_class($result) == 'mysqli_stmt' ){
		                mysqli_stmt_free_result($result);
					}else{
						unset($result);
					}
				}
		    }
	   }      
  */ 
   	
}

?>