SHARE
TWEET

import

a guest Jul 18th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. include 'config.php';
  3. include 'excel_reader.php';
  4. class deleteDuplicate extends Config{
  5.   function __construct(){
  6.     $options = getopt(null, ["fileName:"]);
  7.     $namaFile =$options['fileName'];
  8.     $nameFileExcel = $namaFile;
  9.     $excel = new PhpExcelReader;
  10.     $excel->read("$namaFile");
  11.     $sheet = $excel->sheets[0];
  12.        $x = 2;
  13.        $jumlahData = $sheet['numRows'] - 1;
  14.        while($x <= $sheet['numRows']) {
  15.          $bk = $sheet['cells'][$x][1];
  16.          $ck = $sheet['cells'][$x][2];
  17.          $dk = $sheet['cells'][$x][3];
  18.          $p = $sheet['cells'][$x][4];
  19.          $q = $sheet['cells'][$x][5];
  20.          $kodeUrusan = $bk.".".$ck.".".$dk.".".$p.".".$q;
  21.          $nama = $this->stringDetector($sheet['cells'][$x][6]);
  22.          if(!empty($p)&& $p != "00" && $p != "0" && $p != ""){
  23.            $dataProgramKegiatan = array(
  24.              "bk"=> $bk,
  25.              "ck"=> $ck,
  26.              "dk"=> $dk,
  27.              "p"=> $p,
  28.              "q"=> $q,
  29.              "nama"=> $nama,
  30.            );
  31.            $query = $this->sqlInsert("ref_program",$dataProgramKegiatan);
  32.            $this->sqlQuery($query);
  33.            echo $query.";\n";
  34.          }else{
  35.            $dataUrusan = array(
  36.              "bk"=> $bk,
  37.              "ck"=> $ck,
  38.              "dk"=> $dk,
  39.              "nm_urusan"=> $nama,
  40.            );
  41.            // $query = $this->sqlInsert("ref_urusan",$dataUrusan);
  42.            // $this->sqlQuery($query);
  43.            // echo $query.";\n";
  44.          }
  45.  
  46.  
  47.          // }
  48.         $x++;
  49.       }
  50.   }
  51.  
  52.   function stringDetector($string){
  53.       $string = str_replace("`","",$string);
  54.       $string = str_replace("'","",$string);
  55.       $string = str_replace("?","",$string);
  56.       $string = str_replace(".","",$string);
  57.       return $string;
  58.   }
  59.   function kasihNol($angka){
  60.     if(empty($angka))$angka="00";
  61.     return $angka;
  62.   }
  63.   function generateNol($angka){
  64.     if(empty($angka))$angka="0";
  65.     return $angka;
  66.  }
  67.  
  68. }
  69.  
  70. $wakwaw = new deleteDuplicate();
  71.  
  72.  
  73.  
  74.  
  75.  ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top