<?php

class AppSumberDana extends Database {

	protected $mSqlFile= 'module/sumber_dana/business/appsumberdana.sql.php';
	
	function __construct($connectionNumber=0) {
		parent::__construct($connectionNumber);
		
	}
		
	function GetDataSumberDana($offset, $limit, $sumber_dana='') {
		return $this->Open($this->mSqlQueries['get_data_sumber_dana'], array('%'.$sumber_dana.'%', $offset, $limit));
	}
	
	function GetIdSumberDana() {
		return $this->Open($this->mSqlQueries['get_id_sumber_dana'], array());
	}

	function GetCountDataSumberDana($sumber_dana) {
		$result = $this->Open($this->mSqlQueries['get_count_data_sumber_dana'], array('%'.$sumber_dana.'%'));
		if (!$result) {
			return 0;
		} else {
			return $result[0]['total'];
		}
	}

	function GetDataSumberDanaById($sbdnrId) {
		$result = $this->Open($this->mSqlQueries['get_data_sumber_dana_by_id'], array($sbdnrId));
		return $result;
	}

	function GetDataSumberDanaByArrayId($arrSbdnrId) {
		$sbdnrId = implode("', '", $arrSbdnrId);
		$result = $this->Open($this->mSqlQueries['get_data_sumber_dana_by_array_id'], array($sbdnrId));
		return $result;
	}

//===DO==
	
	function DoAddSumberDana($sbdnrId, $sbdnNama) {
		$result = $this->Execute($this->mSqlQueries['do_add_sumber_dana'], array($sbdnrId, $sbdnNama));
			  #print($this->GetLastError());
		return $result;
	}
	
	function DoUpdateSumberDana($sbdnNama, $sbdnrId) {
		$result = $this->Execute($this->mSqlQueries['do_update_sumber_dana'], array($sbdnNama, $sbdnrId));
	  //$debug = sprintf($this->mSqlQueries['do_update_sumber_dana'], $sbdnrId, $sbdnNama, $tipeunit, $satker, $sbdnrId);
	  //echo $debug;

		return $result;
	}
	
	function DoDeleteSumberDanaById($sbdnrId) {
		$result=$this->Execute($this->mSqlQueries['do_delete_sumber_dana_by_id'], array($sbdnrId));
		return $result;
	}

	function DoDeleteSumberDanaByArrayId($arrSbdnrId) {
		$sbdnrId = implode("', '", $arrSbdnrId);
		$result=$this->Execute($this->mSqlQueries['do_delete_sumber_dana_by_array_id'], array($sbdnrId));
		return $result;
	}
}
?>
