Current File : /home/inlingua/www/sensoriumpsychologists.com/screening/franchise_back/database_admin.php
<?php 
class database
{
	public $new_conn;
	function open_connection()
	{
		// Create connection
	 	$conn = new mysqli($GLOBALS['host_db'], $GLOBALS['user_db'], $GLOBALS['pass_db'], $GLOBALS['name_db']);
	    // Check connection
 	    if ($conn->connect_error) 
    	{
    		die("Connection failed: " . $conn->connect_error);
	 	}
		$this->new_conn = $conn;
		//$this->new_conn->query("SET time_zone = 'Asia/Kolkata'");
		$this->new_conn->query("SET time_zone = '+05:30'");
	}
	
	function real_escape($to_update)
	{
		return $this->new_conn->real_escape_string($to_update);
	}
	
	function close_connection()
	{
		$this->new_conn->close();
	}
	function insert_id()
	{
		return $this->new_conn->insert_id;
	}
	function affected_rows()
	{
		return $this->new_conn->affected_rows;
		
	}
	function START_TRANSACTION()
	{
		return $this->new_conn->query("START TRANSACTION");
	}
	function rollback()
	{
		return $this->new_conn->rollback();
	}
	function commit()
	{
		return $this->new_conn->commit();
	}
	function simply_run_statement_passed($statement)
	{
		if(!$res=$this->new_conn->query($statement))
		{
			return false;
		}
		else
		{
			return $res;
		}
	}
	
	function log_error($file_name,$function_name,$query,$log_id,$log_type,$ip,$browser)
	{
		$this->open_connection_mlm();
		$file_name=$this->real_escape($file_name);
		$function_name=$this->real_escape($function_name);
		$query=$this->real_escape($query);
		$log_id=$this->real_escape($log_id);
		$log_type=$this->real_escape($log_type);
		$ip=$this->real_escape($ip);
		$browser=$this->real_escape($browser);
		$prep="INSERT INTO errors_logged(file_name,function_name,query,log_id,log_type,created_ip,created_browser) VALUES('$file_name','$function_name','$query','$log_id','$log_type','$ip','$browser')";
		$this->simply_run_statement_passed($prep);
		$this->close_connection();
	}
}
?>