<?php 
class Gmodel extends Model
{
	
	function gUpdate($tableName,$where,$qData)
		{	
			foreach($where as $col=>$val)
				$this->db->where($col,$val);		
			$this->db->update($tableName,$qData);		
		}

	function gInsert($tableName,$qData)
		{
			$this->db->insert($tableName, $qData); 
			return $ID = $this->db->insert_id();	
		}
	function gInsertImage($tableName,$qData)
		{
			$this->db->insert($tableName); 
			return $ID = $this->db->insert_id();	
		}
	function gDelete($tableName,$where)
		{
			foreach($where as $col=>$val)
				$this->db->where($col,$val);		
			$this->db->delete($tableName); 
		}


	function gLike($tableName,$where)
		{
			foreach($where as $col=>$val)
				$this->db->like($col,$val);		
			$this->db->insert($tableName); 
		}
	
	function gCountAll($tableName)
		{
			return $this->db->count_all($tableName);		
		}
	
	function gTruncate($tableName)
		{
			$this->db->truncate($tableName); 
		}

	function gSelectStar($tableName)
		{
			$query = $this->db->get($tableName); 
			return $query->result_array();	

		}

	function gSelectWhere($tableName,$where)
		{
			$query = $this->db->get_where($tableName,$where); 
			return $this->db->result_array();	
		}

	function gSelectWhereLimit($tableName,$where,$offset,$per_page)
		{
			$query = $this->db->get_where($tableName,$where,$offset,$per_page); 
			return $this->db->result_array();	
		}

/*====================================================================== End Of G Model ================================ */

	function getAllClients($xxx,$tablenm,$offset,$per_page)
	{
		$query=$this->db->query("Select * from  $tablenm $xxx limit $offset,$per_page");
		return $query->result_array();	
	}

	function getMovieDetails()
		{
			$query=$this->db->query(" select * from movie");
			return $query->result_array();
		}
	function getActorDetails()
		{
			$query=$this->db->query(" select * from actor");
			return $query->result_array();
		}
		
		function getAwardDetails()
		{
			$query=$this->db->query(" select * from awards");
			return $query->result_array();
		}
		
		function getTrailorDetails()
		{
			$query=$this->db->query(" select * from trailer");
			return $query->result_array();
		
		}
	
		function getMovieRecords($catID)
			{
			$query=$this->db->query(" select * from movie $catID ");
			return $query->num_rows();		
			
			}
		

		
		function getAllMovies($catID,$offset,$per_page)
		{
			//echo " select * from movie $catID order by movieID desc limit $offset,$per_page";
			$query=$this->db->query(" select * from movie $catID order by movieID desc limit $offset,$per_page");
			return $query->result_array();
		
		}
		function UpdateImage($image1,$userID)
	{
				$query=$this->db->query("update users set thumbPath='$image1' where userID='$userID'");
	}
	
	//--------------------
	
	function getlocation_1($tablenm,$offset,$per_page )
{
	$query=$this->db->query(" select * from $tablenm limit $offset,$per_page");
	return $query->result_array();
}

function updatelocation_1($tabName,$data1,$gid)
{
	 $this->db->where('gid', $gid);
	$this->db->update($tabName,$data1); 
}

function getlocation($tablenm)
{
	$query=$this->db->query(" select * from $tablenm");
	return $query->result_array();
}
function updatefeature_1($tabName,$data1,$fid)
{
	 $this->db->where('instrumentid', $fid);
	$this->db->update($tabName,$data1); 
}

function countvideo_1($userID)
	{
		$query=$this->db->query(" select * from videos where userID='$userID' ");
		return $query->num_rows();		
		}
 function getMovieDetails_1($userID,$offset,$per_page)
  		{
			$query=$this->db->query("select * from videos where userID='$userID' limit $offset,$per_page ");
			return $query->result_array();		
		}
function insertMovieRecord($data)
		{
				$this->db->insert('videos', $data); 
		}	
		
function updateloc($table,$data,$lid)
{
	 $this->db->where('lid', $lid);
	$this->db->update($table,$data); 
}
function clientDetails($clientID)
		{
			$query=$this->db->query(" select * from clients where clientID='$clientID' limit 1");
			return $query->result_array();
		}
		
 function gSelectWhere_1($tableName,$userid)
 {
 $query=$this->db->query(" select * from $tableName where userID='$userid' ");
			return $query->result_array();
 }	
function getuserfdbk($user)
{
	 $query=$this->db->query("select * from users where userID ='$user' ");
			return $query->result_array();
}
function updateUser($user,$data1)
		{
			
			$this->db->where('userID', $user);
			$this->db->update('users', $data1); 
			
		}
		function updateAds($cid,$data)
		{
			
			$this->db->where('cID', $cid);
			$this->db->update('cads', $data); 
			
		}
		function getClassifield($cid)
		{
			$query=$this->db->query("select * from cads where cID = '$cid'");
			return $query->result_array();
		}
		function getAdDetails($useradID)	
		{
			$query=$this->db->query("select * from userads where useradID = '$useradID'");
			return $query->result_array();
		}
		
		function updateAd($tabName,$data,$useradID)
		{
		 $this->db->where('useradID', $useradID);
		$this->db->update($tabName,$data); 
		}
	
	
	function countuserMails($userID)
	{
		$query=$this->db->query("select * from pmb as p, clients as c where p.performerID = '$userID' and p.userID = c.clientID");
		return $query->num_rows();		
		}
 function getuserMails($userID,$offset,$per_page)
  		{
			$query=$this->db->query("select * from pmb as p, clients as c where p.performerID = '$userID' and p.userID = c.clientID limit $offset,$per_page ");
			return $query->result_array();		
		}
	
	
		function countuserMails1($userID)
	{
		$query=$this->db->query("select * from pmb1 as p, clients as c where p.performerID = '$userID' and p.clientID = c.clientID");
		return $query->num_rows();		
		}
 function getuserMails1($userID,$offset,$per_page)
  		{
			$query=$this->db->query("select * from pmb1 as p, clients as c where p.performerID = '$userID' and p.clientID = c.clientID limit $offset,$per_page ");
			return $query->result_array();		
		}

 function mb($userID)
  		{
			$query=$this->db->query("select * from cads as C, bids as B where C.cID = B.cID and B.userID = '$userID' order by bidID desc ");
			return $query->result_array();		
		}

 function mr($userID)
  		{
			$query=$this->db->query("select * from cads as C, bids as B where C.cID = B.cID and B.userID = '$userID' order by bidID desc ");
			return $query->result_array();		
		}

	

}	
?>