<?php
class Kampus extends Database
{
   protected $mSqlFile= 'module/kampus/business/kampus.sql.php';
   
   function __construct($connectionNumber=0)
   {
      parent::__construct($connectionNumber);
   }
   
   function GetCount($key) {
      $result = $this->Open($this->mSqlQueries['get_count'], array("%$key%", "%$key%"));
      #$sql = sprintf($this->mSqlQueries['get_count']);
      #echo $sql;
      return $result[0]['total'];
   }
   
   function GetData($offset, $limit, $key) {
      $result = $this->Open($this->mSqlQueries['get_data'], array("%$key%", "%$key%", $offset, $limit));
      #$sql = sprintf($this->mSqlQueries['get_data'], "%$key%", $offset, $limit);
      #echo $sql;
      return $result;
   }
   
   function GetDataById($id) {      
      $result = $this->Open($this->mSqlQueries['get_data_by_id'], array($id)); 
      if($result)
         return $result[0];
      else
         return $result;     
   }  
   
   function DoAdd($kode, $nama) {    
      $result = $this->Execute($this->mSqlQueries['do_add'], array($kode, $nama));
      return $result;
   }  
   
   function DoUpdate($kode, $nama, $id) {
      $result = $this->Execute($this->mSqlQueries['do_update'], array($kode, $nama, $id));               
      //$this->mdebug();  
      return $result;
   }   
   
   function DoDelete($id) {
      $result = $this->Execute($this->mSqlQueries['do_delete'], array($id));     
      return $result;
   }
   
}
?>