<?php

class cms_batchmasterMgmt
{
	public $batch_id;
	public $college_id;
	public $batch_name;



	function getAllRecords($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$qry = "SELECT * 
		  FROM cms_batchmaster
		  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 .= "batch_id   ='" . Escape($this->batch_id) . "',";
		$Qry1 .= "college_id   ='" . $_SESSION["VedantnrCollegeId"] . "',";
		$Qry1 .= "batch_name   ='" . Escape($this->batch_name) . "',";

		if ($Qry1 != "") {

			$Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
			$qry = "insert into cms_batchmaster set " . $Qry1 . " ";
			dbQuery($qry);
			$this->batch_id = dbInsertedId();

		}

	}

	function edit()
	{

		$Qry1 = "";
		$Qry1 .= "batch_id   ='" . Escape($this->batch_id) . "',";
		$Qry1 .= "college_id   ='" . $_SESSION["VedantnrCollegeId"] . "',";
		$Qry1 .= "batch_name   ='" . Escape($this->batch_name) . "',";

		if ($Qry1 != "") {
			$Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
			$qry = "update cms_batchmaster set " . $Qry1 . " where  batch_id=" . $this->batch_id;
			dbQuery($qry);
		}

	}

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


?>