<?
	class newsevents
	{
		var $obj1;
		var $con;
		// constructor
		function __construct()
		{
			$this->obj1 = new dboperations();
			$this->con = $this->obj1-> dbconnect();
			
		}
		
		function getnewsevents($newseventsid="",$fields="*",$sql="")
		{
			if ($newseventsid!="")
			{
				$sqltext = "Select $fields from mstnewsevents where newsid='".$newseventsid."' order by newsid desc";
			}
			else if ($sql!="")
			{
				$sqltext = $sql;
			}
			else
			{
				$sqltext = "Select $fields from mstnewsevents order by newsid desc";
			}
				
			$services = $this->obj1->select_query($sqltext);
			if ($services)
			{
				$numrows = $this->obj1->numRows($services);
			}
			if ($numrows ==1)
			{
				while ($serviceslist = mysqli_fetch_assoc($services))
				{
					$servicestr[] = $serviceslist;
				}
			}
			else
			{
				while ($serviceslist = mysqli_fetch_assoc($services))
				{
					$servicestr[] = $serviceslist;
				}
			}
			return $servicestr;
		}
		
		// example for adding press release data
		//            $data['brandname'] = 'brand1';
		//            $data['proudctdesc'] = "product desc";
		//            $data['productimagebig'] = '/images/product1.jpg';
		//            $data = $obj->addproduct($data);
		
		function addnewsevents($newseventsdata)
		{
			if (is_array($newseventsdata)== false)
			{
				return false;
			}
			else
			{
				$fieldnames =  "(";
				$fieldvalues = "(";
				foreach ($newseventsdata as $k => $v) 
				{
					
					$fieldnames .=  ($fieldnames=="(")?"$k":",$k";
					$fieldvalues .= ($fieldvalues=="(")?"'$v'":",'$v'";
				}
				$sqltext = "insert into mstnewsevents ".$fieldnames.") values ".$fieldvalues.")";
				//echo $sqltext;
				$services = $this->obj1->insert_query($sqltext);
				return ($services == 1)?"true":"false";
			}
		}
		function editnewsevents($newseventsdata,$wherecondition)
		{
			if (is_array($newseventsdata)== false)
			{
				return false;
			}
			else
			{
				$fieldnamesvalues =  "set ";
				
				foreach ($newseventsdata as $k => $v) 
				{
					$fieldnamesvalues .=  ($fieldnamesvalues =="set ")?"$k='$v'":",$k='$v'";
				}
				$sqltext = "update mstnewsevents ".$fieldnamesvalues." where ".$wherecondition ;
				//echo $sqltext;
				$services = $this->obj1->update_query($sqltext);
				return ($services == 1)?"true":"false";
				
			}
		}
		function deletenewsevents($newseventsid)
		{
			if($newseventsid)
			{
				$sqltext = "delete from mstnewsevents where newsid='".$newseventsid."'";
				$newsevents = $this->obj1->delete_query($sqltext);
				return ($newsevents == 1)?"true":"false";
			}
		}
		
	}

?>