<?php

class AppWargaNegara extends Database {

	protected $mSqlFile= 'module/warga_negara/business/appwarganegara.sql.php';
	
	function __construct($connectionNumber=0) {
		parent::__construct($connectionNumber);
		
	}
		
	function GetDataWargaNegara($offset, $limit, $warga_negara='') {
		return $this->Open($this->mSqlQueries['get_data_warga_negara'], array('%'.$warga_negara.'%', $offset, $limit));
	}

   function GetIdWargaNegara() {
		return $this->Open($this->mSqlQueries['get_id_warga_negara'], array());
	}

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

	function GetDataWargaNegaraById($wnrId) {
		$result = $this->Open($this->mSqlQueries['get_data_warga_negara_by_id'], array($wnrId));
		return $result;
	}

	function GetDataWargaNegaraByArrayId($arrWnrId) {
		$WnrId = implode("', '", $arrWnrId);
		$result = $this->Open($this->mSqlQueries['get_data_warga_negara_by_array_id'], array($wnrId));
		return $result;
	}

//===DO==
	
	function DoAddWargaNegara($wnrNegara) {
		$result = $this->Execute($this->mSqlQueries['do_add_warga_negara'], array($wnrNegara));
		return $result;
	}
	
	function DoUpdateWargaNegara($wnrNegara, $wnrId) {
		$result = $this->Execute($this->mSqlQueries['do_update_warga_negara'], array($wnrNegara, $wnrId));
	  //$debug = sprintf($this->mSqlQueries['do_update_warga_negara'], $wnrKode, $wnrNama, $tipeunit, $satker, $wnrId);
	  //echo $debug;
		return $result;
	}
	
	function DoDeleteWargaNegaraById($wnrId) {
		$result=$this->Execute($this->mSqlQueries['do_delete_warga_negara_by_id'], array($wnrId));
		return $result;
	}

	function DoDeleteWargaNegaraByArrayId($arrWnrId) {
		$wnrId = implode("', '", $arrWnrId);
		$result=$this->Execute($this->mSqlQueries['do_delete_warga_negara_by_array_id'], array($wnrId));
		return $result;
	}
}
?>
