<?php 
class banana_model 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->insert($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)
		{	//	echo $tableName; print_r($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();	
		}
		
		function gCountAll_1($tableName,$userID)
		{
			$query=$this->db->query("select * from $tableName where userID = '$userID' ");
			return $query->num_rows();	
		}
		function gettable($tableName,$offset,$per_page,$userID)
		{
			$query=$this->db->query("select * from $tableName where userID = '$userID' limit $offset,$per_page");
			return $query->result_array();
		}


	function gSelectWhere1($tableName,$where)
		{
		
			/*$query = $this->db->get_where($tableName,$where); 
			return $query->result_array();	*/
			foreach ($where as $w)
		{
			$s = $w['sID'];
		}
		$query=$this->db->query(" select * from $tableName where sID = '$s'");
			//$query = $this->db->get_where($tableName,$where); 
			return $query->result_array();	
		}

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

	function getExhibitor($tableName,$offset,$per_page)
	{
		$query=$this->db->query("select * from $tableName limit $offset,$per_page");
			return $query->result_array();
	}
	function cntforumThread()
		{
			$query=$this->db->query("select * from sector where pID = 0 and forumtype = 0");
			return $query->num_rows();		
		}
		
		function getforumThread($offset,$per_page)
		{
			$query=$this->db->query("select * from sector where pID = 0 and forumtype = 0 limit $offset,$per_page");
			return $query->result_array();
		}
		
		function cntforumThread1()
		{
			$query=$this->db->query("select * from sector where pID = 0 and forumtype = 1");
			return $query->num_rows();		
		}
		
		function getforumThread1($offset,$per_page)
		{
			$query=$this->db->query("select * from sector where pID = 0 and forumtype = 1 limit $offset,$per_page");
			return $query->result_array();
		}

		
		
		

		function cntforumPost($sID)
		{
			$query=$this->db->query("select * from sector_post where sID = '$sID' ");
			return $query->num_rows();		
		}
		
		function getforumPost($sID,$offset,$per_page)
		{	//echo "select * from sector_post where sID = '$sID' limit $offset,$per_page";
			$query=$this->db->query("select * from sector_post where sID = '$sID' and spName <> '' limit $offset,$per_page");
			return $query->result_array();
		}

		function cntforumPostReply($spID)
		{
			$query=$this->db->query("select * from sector_post_reply where spID = '$spID' ");
			return $query->num_rows();		
		}
		
		function getforumPostReply($spID,$offset,$per_page)
		{	//echo "select * from sector_post_reply where spID = '$spID' limit $offset,$per_page";
			$query=$this->db->query("select * from sector_post_reply where spID = '$spID' limit $offset,$per_page");
			return $query->result_array();

		}

		function cntShows($time)
		{	
			$query=$this->db->query("SELECT * FROM showtable WHERE active = 1 and ticketsale = 1 and time1 > '$time'");
			return $query->num_rows();		
		}
		
		function getShows($time,$offset,$per_page)
		{	
			$query=$this->db->query("SELECT * FROM showtable WHERE active = 1 and ticketsale = 1 and time1 > '$time' limit $offset,$per_page");
			return $query->result_array();
		}

		function cntShows1($time)
		{	
			$query=$this->db->query("SELECT * FROM showtable WHERE active = 1 and time1 > '$time'");
			return $query->num_rows();		
		}
		
		function getShows1($time,$offset,$per_page)
		{	
			$query=$this->db->query("SELECT * FROM showtable WHERE active = 1 and time1 > '$time' limit $offset,$per_page");
			return $query->result_array();
		}

		function SelectemailSubscribe($tableName,$where)
		{ // echo "select * from $tableName where emailID = '$where'";
			$query=$this->db->query("select * from $tableName where emailID = '$where' ");
			return $query->num_rows();		
		}

		function cntvideo4_Video()
		{	//SELECT * FROM videos WHERE videoimage <> ' '
					$query = $this->db->query("SELECT * FROM contact ");
					return $query->num_rows();
		}
		function cntvideo_4_Video($offset,$per_page)
		{  //echo "SELECT * FROM contact limit $offset,$per_page";
					$query = $this->db->query("SELECT * FROM contact order by odr  limit $offset,$per_page");
			return $query->result_array();					
		}
		
	function getbu($id,$offset,$per_page)
	{
		$query=$this->db->query("select * from business where userID = '$id' limit $offset,$per_page");
			return $query->result_array();
	}
	function cntbu($id)
		{
			$query=$this->db->query("select * from business where userID = '$id'");
			return $query->num_rows();		
		}

		
		

}

?>