<?php

class AppPredikatLulus extends Database {

	protected $mSqlFile= 'module/predikat_lulus/business/apppredikatlulus.sql.php';
	
	function __construct($connectionNumber=0) {
		parent::__construct($connectionNumber);
		
	}
		
   function GetDataPredikatLulus($offset,$limit,$namaLokal,$namaAsing) {
      $result =$this->Open($this->mSqlQueries['get_data_predikat'], array('%'.$namaLokal.'%','%'.$namaAsing.'%',$offset,$limit));
	     return $result;
  //print_r ($result);
  }
  	function GetCountDataPredikatLulus($namaLokal,$namaAsing) {
		$result = $this->Open($this->mSqlQueries['get_count_data_predikat'], array('%'.$namaLokal.'%','%'.$namaAsing.'%'));
		//print $this->GetLastError();
      if (!$result) {
			return 0;
		} else {
			return $result[0]['total'];
		}
	}
  
  function GetLastIdPredikatLulus( ){
    $result=$this->Open($this->mSqlQueries['get_last_predikat_id'], array());
    return $result;
  }

	function GetDataPredikatLulusById($predikatId) {
		$result = $this->Open($this->mSqlQueries['get_data_predikat_by_id'], array($predikatId));
		return $result;
		//print $this->GetLastError();
	}

	function GetDataPredikatByArrayId($arrPredikatId) {
		$predikatId= implode("', '", $arrPredikatId);
		$result = $this->Open($this->mSqlQueries['get_data_predikat_by_array_id'], array($predikatId));
		return $result;
	}

//===DO==
	
	function DoAddPredikatLulus($idPredikat,$namaPredikat,$namaAsingPredikat) {
		$result = $this->Execute($this->mSqlQueries['do_add_predikat_lulus'], array($idPredikat,$namaPredikat,$namaAsingPredikat));
    return $result;
  //print $this->GetLastError();
	}
	
	function DoUpdatePredikatLulus($idPredikat,$namaPredikat,$namaAsingPredikat) {
		$result = $this->Execute($this->mSqlQueries['do_update_predikat_lulus'], array( $namaPredikat,$namaAsingPredikat,$idPredikat,));
	  //$debug = sprintf($this->mSqlQueries['do_update_predikat'], $agamaId, $agamaNama, $tipeunit, $satker, $agamaId);
	  //echo $debug;
		return $result;
	}
	
	function DoDeletePredikatLulusById($idPredikat) {
		$result=$this->Execute($this->mSqlQueries['do_delete_predikat_lulus_by_id'], array($idPredikat));
		return $result;
	}

	function DoDeletePredikatLulusByArrayId($arrPredikatId) {
		$idPredikat = implode("', '", $arrPredikatId);
		$result=$this->Execute($this->mSqlQueries['do_delete_predikat_lulus_by_array_id'], array($idPredikat));
		//print $this->GetLastError();
    return $result;
	}
}
?>
