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