<?php
class cms_branchsemesterMgmt
{
	public $branchsemester_id;
	public $college_id;
	public $branch_id;
	public $semester_id;
	public $noofdiv;


	function getAllRecords($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$qry = " SELECT bsem.*,
				 branch_name,
				 semester_name
		  FROM 
		  			cms_branchsemester bsem,
					cms_semestermaster sem,
					cms_branchmaster branch
					
		Where 
			branch.branch_id = bsem.branch_id
			AND sem.semester_id=bsem.semester_id 
			AND bsem.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 .= "branchsemester_id   ='" . Escape($this->branchsemester_id) . "',";
		$Qry1 .= "college_id ='" . Escape($_SESSION["VedantnrCollegeId"]) . "',";
		$Qry1 .= "branch_id   ='" . Escape($this->branch_id) . "',";
		$Qry1 .= "semester_id   ='" . Escape($this->semester_id) . "',";
		$Qry1 .= "noofdiv   ='" . Escape($this->noofdiv) . "',";
		if ($Qry1 != "") {
			$Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
			$qry = "insert into cms_branchsemester set " . $Qry1 . " ";
			dbQuery($qry);
			$this->branchsemester_id = dbInsertedId();
		}

	}

	function edit()
	{
		$Qry1 = "";
		$Qry1 .= "branchsemester_id   ='" . Escape($this->branchsemester_id) . "',";
		$Qry1 .= "college_id ='" . Escape($_SESSION["VedantnrCollegeId"]) . "',";
		$Qry1 .= "branch_id   ='" . Escape($this->branch_id) . "',";
		$Qry1 .= "semester_id   ='" . Escape($this->semester_id) . "',";
		$Qry1 .= "noofdiv   ='" . Escape($this->noofdiv) . "',";
		if ($Qry1 != "") {
			$Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
			$qry = "update cms_branchsemester set " . $Qry1 . " where  branchsemester_id=" . $this->branchsemester_id;
			dbQuery($qry);
		}

	}


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

}
?>