Skip to main content

Double Inset dua database

<?php
//mysql_connect
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "surat";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
 if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

//postgresql
$host = "localhost";
$user = "postgres";
$pass = "........";
$db = "dikti";

$con = pg_connect("host=$host dbname=$db user=$user password=$pass")
    or die ("Could not connect to server\n");

   
//ambil data

$nomor= "";

$tanggal_agenda = $_POST["tanggal_agenda"];


function rubah_tgl_th($th)
{
    $exp = explode(' ',$th);
    if (count($exp) == 3)
    {
        $th =$exp[2];
    }
    return $th;
}

//rubah tanggal ke bulan ----
function rubah_tgl_bl($bl)
{
    $exp = explode(' ',$bl);
    if (count($exp) == 3)
    {
        $bl =$exp[1];
    }
    return $bl;
}

//rubah tanggal ke hari ----
function rubah_tgl_hr($hr)
{
    $exp = explode(' ',$hr);
    if (count($exp) == 3)
    {
        $hr =$exp[0];
    }
    return $hr;
}

$tgta= rubah_tgl_hr($tanggal_agenda);
$blta= rubah_tgl_bl($tanggal_agenda);
$thta= rubah_tgl_th($tanggal_agenda);
$jamta=  "";
$na=  $_POST["na"];
$na1=  $_POST["na1"];
$na2=  $_POST["na2"];
$na3=  $_POST["na3"];

$tanggal_surat_masuk = $_POST["tanggal_surat_masuk"];
$tgts= rubah_tgl_hr($tanggal_surat_masuk);
$blts= rubah_tgl_bl($tanggal_surat_masuk);
$thts= rubah_tgl_th($tanggal_surat_masuk);

$ns=  $_POST["ns"];
$klm=  $_POST["klm"];
$lokasi=  $_POST["lokasi"];
$asr=  $_POST["asr"];
$hl=  $_POST["hl"];
$kpd=  $_POST["kpd"];
$tgldis=  $_POST["tgldis"];
$tgldis1=  $_POST["tgldis1"];
$jamds=  $_POST["jamds"];
$jamds1=  $_POST["jamds1"];
$ds1=  $_POST["ds1"];
$ds2=  $_POST["ds2"];
$ds3=  $_POST["ds3"];
$ds4=  $_POST["ds4"];
$ds5=  $_POST["ds5"];
$ids1=  $_POST["ids1"];
$ids2=  $_POST["ids2"];
$ids3=  $_POST["ids3"];
$ids4=  $_POST["ids4"];
$ids5=  $_POST["ids5"];
$td1=  $_POST["td1"];
$tgtd1=  $_POST["tgtd1"];
$td2=  $_POST["td2"];
$tgtd2=  $_POST["tgtd2"];
$td3=  $_POST["td3"];
$tgtd3=  $_POST["tgtd3"];
$td4=  $_POST["td4"];
$tgtd4=  $_POST["tgtd4"];
$td5=  $_POST["td5"];
$tgtd5=  $_POST["tgtd5"];
$ntd1=  $_POST["ntd1"];
$ntd2=  $_POST["ntd2"];
$ntd3=  $_POST["ntd3"];
$ntd4=  $_POST["ntd4"];
$ntd5=  $_POST["ntd5"];

//sql masuk

$sql = "INSERT INTO `dpa2016` VALUES ('$nomor', '$tgta', '$blta', '$thta', '$jamta', '$na', '$na1', '$na2', '$na3', '$tgts', '$blts', '$thts', '$ns', '$klm', '$lokasi', '$asr', '$hl', '$kpd', '$tgldis', '$tgldis1', '$jamds', '$jamds1', '$ds1', '$ds2', '$ds3', '$ds4', '$ds5', '$ids1', '$ids2', '$ids3', '$ids4', '$ids5', '$td1', '$tgtd1', '$td2', '$tgtd2', '$td3', '$tgtd3', '$td4', '$tgtd4', '$td5', '$tgtd5', '$ntd1', '$ntd2', '$ntd3', '$ntd4', '$ntd5')";
if (mysqli_query($conn, $sql)) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . mysqli_error($conn);


//sql postgre
$sql_postgre = "INSERT INTO surat_masuk VALUES ('$nomor', '$tgta', '$blta', '$thta', '$jamta', '$na', '$na1', '$na2', '$na3', '$tgts', '$blts', '$thts', '$ns', '$klm', '$lokasi', '$asr', '$hl', '$kpd', '$tgldis', '$tgldis1', '$jamds', '$jamds1', '$ds1', '$ds2', '$ds3', '$ds4', '$ds5', '$ids1', '$ids2', '$ids3', '$ids4', '$ids5', '$td1', '$tgtd1', '$td2', '$tgtd2', '$td3', '$tgtd3', '$td4', '$tgtd4', '$td5', '$tgtd5', '$ntd1', '$ntd2', '$ntd3', '$ntd4', '$ntd5')";
$result = pg_query($con, $sql_postgre);   
                 
pg_close($con);
mysqli_close($conn);

header("location: surat_masuk_internal.php");

?>

Comments

Popular posts from this blog

FPDF dengan CodeIgniter

Cetak Surat Keputusan Controller: <?php //File in controller named surat_keputusan.php defined('BASEPATH') OR exit('No direct script access allowed'); class Cetak_surat_keputusan extends CI_Controller { public function __construct()     {         parent::__construct();         $this->load->helper('url');         $this->load->database();                $this->db->select();         $this->db->from('surat.config_sk');                $query = $this->db->get();                 return $query->result();             } public function index() {      ...

Layar Biru versi PHP Bagian 1 (file prefil_dbf.php)

file config.php <?php $db_uname = 'root'; $db_passwd = ''; $db_name = 'layar_biru'; //database yang dipilih $db_host = 'localhost'; $xbase_dir = 'D:\ACADEMIC\htdocs\layar_biru\files'; $die_on_mysql_error = false; // when investigating errors, set this to true $from_encoding=""; //Encoding of database, e.g. CP866 or empty, if convert is not required     file prefil.dbf   <?php include "config.php";            // please copy the config.sample.php and edit the correct fields include "classes/XBase/Table.php"; include "classes/XBase/Column.php"; include "classes/XBase/Record.php"; include "classes/DBFhandler.php"; use XBase\Table;  // Initializing vars ini_set( 'memory_limit', '2048M' ); set_time_limit( 0 ); $time_start = time(); $files = scandir($xbase_dir) or die ("Error! Could not open directory '$xbase_dir'."); $conn = new mysqli($db_host,...

Converter dbf ke MYSQL

Banyak tool yang dipakai dan direkomendasikan orang untuk mengkonversi database , khususnya DBF ke MySQL. Ada yang menggunakan / menyarankan Navicat, CDBF for Linux , dbf2mysql, MySQL Migration Toolkit , dll. Bahkan ada pula yang mau bersusah-payah melakukannya dengan cara tradisionil dan ribet, yaitu dengan menggunakan MS Access: ekspor file ini, ganti syntax-nya menjadi sql, bla..bla..bla… dsb. Setelah menyimak semuanya, endingnya ternyata gak bikin happy. Meski begitu saya hargai effort mereka. Karena dari upaya mereka itulah kita menjadi tahu bahwa tool yang ini dan itu tidak cocok  dipakai. Tool yang saya pakai adalah Full Convert Enterprise (FCE). Komen saya terhadap tool ini cuma satu, keren! Kenapa? Karena bukan hanya source DBF saja yang bisa di-convert, tapi juga source lainnya (Interbase/Firebird, Oracle , Paradox, SQL Server, dll). Download: Full Convert Enterprise Full Version di sini (size 4.7 MB) Password: bayusibond Berikut adalah langkah-langkah m...