<?php
class ExamMgmt
{
	public $exam_id;
	public $college_id;
	public $exam_name;

	function getAllRecords($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$qry = "";
		$qry = "SELECT * FROM cms_exammaster WHERE college_id = " . $_SESSION['VedantnrCollegeId'];

		if ($condition != "") {
			$qry .= $condition;
		}

		if ($order_field != "" && $order_type != "") {
			$qry .= " order by $order_field $order_type";
		}

		if (intval($limit) > 0 && intval($start) >= 0) {
			$qry .= " Limit $start , $limit";
		}

		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}

	function add()
	{
		$Qry1 = "";
		$Qry1 .= "college_id='" . Escape($_SESSION['VedantnrCollegeId']) . "',";
		$Qry1 .= "exam_name='" . Escape($this->exam_name) . "',";
		$Qry1 .= "login_id='" . Escape($_SESSION['aUserId']) . "',";
		$Qry1 .= "createdon='" . Escape(date('Y-m-d h:i:s')) . "',";
		if ($Qry1 != "") {
			$Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
			$qry = "insert into cms_exammaster set " . $Qry1 . " ";
			dbQuery($qry);
			$this->exam_id = dbInsertedId();
		}
	}

	function edit()
	{
		$Qry1 = "";
		$Qry1 .= "exam_name='" . Escape($this->exam_name) . "',";
		$Qry1 .= "login_id='" . Escape($_SESSION['aUserId']) . "',";
		$Qry1 .= "createdon='" . Escape(date('Y-m-d h:i:s')) . "',";
		if ($Qry1 != "") {
			$Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
			$qry = "update cms_exammaster set " . $Qry1 . " where exam_id=" . $this->exam_id;
			dbQuery($qry);
		}
	}

	function delete()
	{
		$qry = "delete from cms_exammaster where exam_id in (" . $this->exam_id . ") ";
		dbQuery($qry);
	}


	function getexam($exam_name,$exam_id)
	{
		$qry = "";
		$qry = "SELECT * FROM cms_exammaster WHERE exam_name = '$exam_name' AND exam_id != $exam_id";
	
		
		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}
}
?>