create class file for connection in php MySQLi with Time zone

<?php
 class Connection
{
	var $link;
public	function Connecton()
{
        date_default_timezone_set('Asia/Kolkata'); 
	                $this->link=mysqli_connect("localhost","root","","mvc");	
return $this->link;

	}
	
	public function Query($cmd)
	{
			$query=mysqli_query($this->link,$cmd);
                       $data = array();
			while ($row = $query->fetch_assoc()) {
					$data[] = $row;
				}
	  			$result = new \stdClass();
				$result->num_rows = $query->num_rows;
				$result->row = isset($data[0]) ? $data[0] : array();
				$result->rows = $data;

				$query->close();

				return $result ;
		
	}
	public function NonQuery($cmd)
	{
			mysqli_query($this->link,$cmd);
			if(mysqli_insert_id($this->link)>0)
			{
				return mysqli_insert_id($this->link);
			}
			else
			{
				return mysqli_affected_rows($this->link);
			}
			
			
		
	}
}

?>


Leave a Reply