<?php class DBController {
	private $host = "localhost";
	private $user = "shaftcrmco_user";
	private $password = "@1TesT1@123";
	private $database = "shaftcrmco_crmsoftware";
	
	function __construct() {
		$conn = $this->connectDB();
		if(!empty($conn)) {
			$this->selectDB($conn);
		}
	}
	
	function connectDB() {
		$conn = mysqli_connect("localhost", "shaftcrmco_user", "@1TesT1@123", "shaftcrmco_crmsoftware");
		
		//$conn = mysqli_connect($this->host,$this->user,$this->password);
		return $conn;
	}
	
	function selectDB($conn) {
		//mysqli_select_db($conn,$this->database);
		mysqli_select_db($conn, "crm");
	}
	
	function runQuery($query) {
	$conn = mysqli_connect("localhost", "shaftcrmco_user", "@1TesT1@123", "shaftcrmco_crmsoftware");
		$result = mysqli_query($conn,$query);
		while($row=mysqli_fetch_assoc($result)) {
			$resultset[] = $row;
		}		
		if(!empty($resultset))
			return $resultset;
	}
	
	function numRows($query) {
		$result  = mysqli_query($conn,$query);
		$rowcount = mysqli_num_rows($result);
		return $rowcount;	
	}
}
?>