<?
	class pressrelease
	{
		var $obj1;
		var $con;
		// constructor
		function __construct()
		{
			$this->obj1 = new dboperations();
			$this->con = $this->obj1-> dbconnect();
			
		}
		
		function getpressrelease($pressreleaseid="",$fields="*",$sql="")
		{
			if ($pressreleaseid!="")
			{
				$sqltext = "Select $fields from mstpressrelease where pressreleaseid='".$pressreleaseid."' order by pressreleaseid desc";
			}
			else if ($sql!="")
			{
				$sqltext = $sql;
			}
			else
			{
				$sqltext = "Select $fields from mstpressrelease order by pressreleaseid 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 addpressrelease($pressreleasedata)
		{
			if (is_array($pressreleasedata)== false)
			{
				return false;
			}
			else
			{
				$fieldnames =  "(";
				$fieldvalues = "(";
				foreach ($pressreleasedata as $k => $v) 
				{
					
					$fieldnames .=  ($fieldnames=="(")?"$k":",$k";
					$fieldvalues .= ($fieldvalues=="(")?"'$v'":",'$v'";
				}
				$sqltext = "insert into mstpressrelease ".$fieldnames.") values ".$fieldvalues.")";
				//echo $sqltext;
				$services = $this->obj1->insert_query($sqltext);
				return ($services == 1)?"true":"false";
				
			}
		}
		function editpressrelease($pressreleasedata,$wherecondition)
		{
			if (is_array($pressreleasedata)== false)
			{
				return false;
			}
			else
			{
				$fieldnamesvalues =  "set ";
				
				foreach ($pressreleasedata as $k => $v) 
				{
					$fieldnamesvalues .=  ($fieldnamesvalues =="set ")?"$k='$v'":",$k='$v'";
				}
				$sqltext = "update mstpressrelease ".$fieldnamesvalues." where ".$wherecondition ;
				//echo $sqltext;
				$services = $this->obj1->update_query($sqltext);
				return ($services == 1)?"true":"false";
				
			}
		}
		function deletepressrelease($pressreleaseid)
		{
			if($pressreleaseid)
			{
				$sqltext = "delete from mstpressrelease where pressreleaseid='".$pressreleaseid."'";
				$pressrelease = $this->obj1->delete_query($sqltext);
				return ($pressrelease == 1)?"true":"false";
			}
		}
		
	}

?>