<?php
class AppKota extends Database {

	protected $mSqlFile= 'module/kota/business/appkota.sql.php';

	function __construct($connectionNumber=0) {
		parent::__construct($connectionNumber);
		//
	}
	function GetCountDataKota($kodeKota,$namaKota,$namaProp){
      $result =$this->Open($this->mSqlQueries['get_count_data_kota'], array('%'.$kodeKota.'%', '%'.$namaKota.'%', '%'.$namaProp.'%'));
	   if (!$result) {
			return 0;
		} else {
			return $result[0]['total'];
		}
   }
   function GetDataKota($kodeKota,$namaKota,$namaProp,$offset,$limit){
      $result=$this->Open($this->mSqlQueries['get_data_kota'],array('%'.$kodeKota.'%','%'.$namaKota.'%','%'.$namaProp.'%',$offset,$limit));
      return $result;
   }
   function GetDataKotaById($kodeKota){
      $result=$this->Open($this->mSqlQueries['get_data_kota_by_id'],array($kodeKota));
      //print($this->GetLastError());
      return $result;
   }
   function GetDataPropinsi(){
      return $this->Open($this->mSqlQueries['get_data_propinsi'],array());
   }
   function GetDataPropinsiById($kodeProp){
      $result=$this->Open($this->mSqlQueries['get_data_propinsi_by_id'],array($kodeProp));
      return $result;
   }
   
//==do===
   function DoAddKota($kotaKode,$kotaNama,$kotaPropKode){
      $result=$this->Execute($this->mSqlQueries['do_add_kota'],array($kotaKode,$kotaNama,$kotaPropKode));
      return $result;
   }
   function DoUpdateKota($kotaKode,$kotaNama,$kotaPropKode,$kodeKota){
      $result=$this->Execute($this->mSqlQueries['do_update_kota'],array($kotaKode,$kotaNama,$kotaPropKode,$kodeKota));
      return $result;
   }
   function DoDeleteKotaById($kodeKota){
      $result=$this->Execute($this->mSqlQueries['do_delete_kota_by_id'],array($kodeKota));
      return $result;   
   }
   function DoDeleteKotaByArrayId($arrKodeKota){
      $kodeKota=implode("', '", $arrKodeKota);
      $result=$this->Execute($this->mSqlQueries['do_delete_kota_by_array_id'],array($kodeKota));
      return $result;   
   }
   function DoImportFileDbfKota($kotaKode,$kotaNama,$kotaPropKode,$kotaKode,$kotaNama,$kotaPropKode){
      $result=$this->Execute($this->mSqlQueries['do_import_file_dbf_kota'],array($kotaKode,$kotaNama,$kotaPropKode,$kotaKode,$kotaNama,$kotaPropKode));
      return $result;
   }
   
}
?>
