<?php 
include_once 'class.database.php';
class ManageDrafts{
	public $link;
	function __construct()
	{
		$db_connection = new dbConnection();
		$this ->link = $db_connection->connect();

		return $this->link;
	}


	function Add($drfdesc, $drftitle, $drfpublished , $aid)
	{
		global $prefix;
		$query = $this->link->prepare("INSERT INTO `".$prefix."drafts` (`drfdesc` , `drftitle` , `drfpublished` , `aid` , `drfdate`) VALUES (?,?,?,?,NOW()) ");
		$values = array($drfdesc, $drftitle, $drfpublished , $aid);
		$query->execute($values);
		// print_r ($query->errorInfo());
		$counts= $query->rowCount();
		return $counts;
	}



	function Update($drfdesc, $drftitle, $drfpublished, $drfid)
	{
		global $prefix;
		$query = $this->link->prepare("UPDATE `".$prefix."drafts` SET `drfdesc`=? , `drftitle`=? , `drfpublished`=? WHERE `drfid`=? ");
		$values = array($drfdesc, $drftitle, $drfpublished, $drfid);
		$query->execute($values);
		// print_r ($query->errorInfo());
		return $query->rowCount();
	}

	
		function Getinfo($field,$value)
	{
		global $prefix;
		$query = $this->link->prepare("SELECT * FROM `".$prefix."drafts` WHERE $field=? ORDER BY drfdate desc");
		$values = array($value);
		$query->execute($values);
		return $query->fetchAll();
	}

	function Delete($id)
	{
		global $prefix;
		$query = $this->link->prepare("DELETE FROM `".$prefix."drafts` WHERE drfid=?");
		$values = array($id);
		$query->execute($values);
		return $query->rowCount();
	}
}
 ?>