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

		return $this->link;
	}
	function Add($aid ,$tycode ,$tytitle ,$tycomments)
	{
		global $prefix;
		$query = $this->link->prepare("INSERT INTO `".$prefix."issue_types` (`aid`, `tycode`, `tytitle`, `tycomments`) VALUES (?,?,?,?) ");
		$values = array($aid ,$tycode ,$tytitle ,$tycomments);
		$query->execute($values);
		// print_r ($query->errorInfo());
		$counts= $query->rowCount();
		return $counts;
	}

	function Update($tycode ,$tytitle ,$tycomments ,$tyid)
	{
		global $prefix;
		$query = $this->link->prepare("UPDATE `".$prefix."issue_types` SET `tycode`=?, `tytitle`=?, `tycomments`=? WHERE `tyid`=? ");
		$values = array($tycode ,$tytitle ,$tycomments ,$tyid);
		$query->execute($values);
		// print_r ($query->errorInfo());
		return $query->rowCount();
	}

	function GetList()
	{
		global $prefix;
		$query = $this->link->query("SELECT * FROM `".$prefix."issue_types` ");
		// $values = array($where);
		// $query->execute($values);
		// print_r ($query->errorInfo());
		return $query->fetchAll();
	}
 
		function Getinfo($field,$value)
	{
		global $prefix;
		$query = $this->link->prepare("SELECT * FROM `".$prefix."issue_types` WHERE $field=?");
		$values = array($value);
		$query->execute($values);
		return $query->fetchAll();
	}

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