<?php

class AppAgama extends Database {

	protected $mSqlFile= 'module/agama/business/appagama.sql.php';
	
	function __construct($connectionNumber=0) {
		parent::__construct($connectionNumber);
		#
	}
		
	function GetDataAgama($offset, $limit, $agama='') {
		$result=$this->Open($this->mSqlQueries['get_data_agama'], array('%'.$agama.'%', $offset, $limit));
      return $result;
	}
   
   function GetIdAgama() {
		$result=$this->Open($this->mSqlQueries['get_id_agama'], array());
      return $result;
	}
   
	function GetCountDataAgama($agama) {
		$result = $this->Open($this->mSqlQueries['get_count_data_agama'], array('%'.$agama.'%'));
		if (!$result) {
			return 0;
		} else {
			return $result[0]['total'];
		}
	}

	function GetDataAgamaById($agamaId) {
		$result = $this->Open($this->mSqlQueries['get_data_agama_by_id'], array($agamaId));
		return $result;
	}

	function GetDataAgamaByArrayId($arrAgamaId) {
		$agamaId = implode("', '", $arrAgamaId);
		$result = $this->Open($this->mSqlQueries['get_data_agama_by_array_id'], array($agamaId));
		return $result;
	}

//===DO==
	
	function DoAddAgama($agamaNama) {
		$result = $this->Execute($this->mSqlQueries['do_add_agama'], array($agamaNama));
		return $result;
	}
	
	function DoUpdateAgama($agamaNama, $agamaId) {
		$result = $this->Execute($this->mSqlQueries['do_update_agama'], array($agamaNama, $agamaId));
	  //$debug = sprintf($this->mSqlQueries['do_update_agama'], $agamaKode, $agamaNama, $tipeunit, $satker, $agamaId);
	  //echo $debug;
		return $result;
	}
	
	function DoDeleteAgamaById($agamaId) {
		$result=$this->Execute($this->mSqlQueries['do_delete_agama_by_id'], array($agamaId));
		return $result;
	}

	function DoDeleteAgamaByArrayId($arrAgamaId) {
		$agamaId = implode("', '", $arrAgamaId);
		$result=$this->Execute($this->mSqlQueries['do_delete_agama_by_array_id'], array($agamaId));
		return $result;
	}
}
?>
