<?php
class DBController {
	private $host = "localhost";
	private $user = "upiplcrm_upiplcrm";
	private $password = "T7?XazRODch!";
	private $database = "upiplcrm_crm";
	
	function __construct() {
		$conn = $this->connectDB();
		if(!empty($conn)) {
			$this->selectDB($conn);
		}
	}
	
	function connectDB() {
		$conn = mysqli_connect("localhost", "upiplcrm_upiplcrm", "T7?XazRODch!", 
			"upiplcrm_crm");
		//$conn = mysql_connect($this->host,$this->user,$this->password);
		return $conn;
	}
	
	function selectDB($conn) {
		//mysql_select_db($this->database);
		mysqli_select_db($conn, "upiplcrm_crm");
	}
	
	function runQuery($query) {
			$conn = mysqli_connect("localhost", "upiplcrm_upiplcrm", "T7?XazRODch!", "upiplcrm_crm");
		//$conn = mysql_connect($this->host,$this->user,$this->password);
		$result = mysqli_query($conn,$query);
		while($row=mysqli_fetch_assoc($result)) {
			$resultset[] = $row;
		}		
		if(!empty($resultset))
			return $resultset;
	}
	
	function numRows($query) {
		$result  = mysqli_query($query);
		$rowcount = mysqli_num_rows($result);
		return $rowcount;	
	}
}
?>