<?php

/*
//Untuk Connect Datab ase Oracle
//  * setting php.ini, cari dan aktifkan :
//      - extension=php_oci8.dll
$database="DEV";  // buat test
$database="PROD"; // buat real
$user = 'APPS';
$password = 'APPS';
$conn_oci = @oci_connect($user,$password,$database);
if (!$conn_oci) {
    $e = oci_error();
    trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
else
{
//	echo "Connection ORACLE succeeded => ".$database."<br>";
	//  ===== sample Query ====
	//$q = "SELECT * FROM AP.apps_lpp_header";
	//$stid = oci_parse($conn_oci, $q);	
	//$r = oci_execute($stid) or die ("Can not connect");
	//$d = oci_fetch_array ($stid, OCI_ASSOC);
	//print_r($d);
	//oci_close($conn_oci);
	//die();
	//
}
*/

/*-------------
//Utk Conncect Database DB2
//  * setting php.ini, cari dan aktifkan :
//      - extension=php_ibm_db2.dll
$database = 'NOWSTX'; //server live
//$database = 'NOWSEP28';  //server test
$user = 'db2admin';
$password = 'Db2stx';
$hostname = '20.88.1.5'; //22 server live 8
//$hostname = '20.88.1.7'; //server demo
$port = 50000;
$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;" .
  "HOSTNAME=$hostname;PORT=$port;PROTOCOL=TCPIP;UID=$user;PWD=$password;";
$conn_db2 = db2_connect($conn_string, '', '');
if ($conn_db2) {
//  echo "Connection DB2 succeeded => ".$database."<br>";
	/*  ===== sample Query ====
	  $table_name="purchaseorder";
	  $query = "
		SELECT * FROM (      
		  SELECT
			ROW_NUMBER() OVER (ORDER BY CUSTOMERSUPPLIERCODE ASC) AS rownum,
			ORDERPARTNER.CUSTOMERSUPPLIERTYPE, ORDERPARTNER.CUSTOMERSUPPLIERCODE, BUSINESSPARTNER.LEGALNAME1, ORDERPARTNER.MARKETCODE, ORDERPARTNER.ORDERCATEGORYCODE, ORDERPARTNER.CREATIONUSER, ORDERPARTNER.LASTUPDATEUSER
		  FROM DB2ADMIN.BUSINESSPARTNER BUSINESSPARTNER, DB2ADMIN.ORDERPARTNER ORDERPARTNER
		  WHERE BUSINESSPARTNER.NUMBERID = ORDERPARTNER.ORDERBUSINESSPARTNERNUMBERID AND ((ORDERPARTNER.CUSTOMERSUPPLIERTYPE='1'))
		)
		";
	  $d=db2_exec($conn_db2,$query) or die(db2_conn_error()); 
	  $r=db2_fetch_assoc($d);
	  print_r($r);
      db2_close($conn_db2);
	  die();
	*/
/*--------------
}
else {
    echo "Connection DB2 failed. <br>";
}
----------------*/
//aktifkan session

//Utk Conncect Database MYSQL
//  * setting php.ini, cari dan aktifkan :
//      - extension=php_mysql.dll
//      - extension=php_mysqli.dll
// we connect to localhost at port 3306

//open database SAP
//$db_ip	='192.168.0.60';  //ini server live
$db_ip	='localhost';
$db_user='root';
$db_pass='uSS10nl1n3';
$database="bprsap";
$conn_mysql = mysqli_connect($db_ip,$db_user,$db_pass, $database);
// Check connection
if (!$conn_mysql) {
  //die ("Failed to connect to MySQL: " . mysqli_connect_error());
	printf("Connect failed: %s\n", mysqli_connect_error());
	exit();
}else{
	$_SESSION["conn_mysql"]="1";
}

//open data login
//$db_ip	='192.168.0.60';// 'localhost';// ke server '192.168.0.60';     //ini 'localhost'
$db_ip	= 'localhost';
$db_user='root';
$db_pass='uSS10nl1n3';
$datalogin="stock";
//model lama => $conn_login = mysqli_connect($db_ip,$db_user,$db_pass, $datalogin);
$conn_login =new mysqli($db_ip,$db_user,$db_pass, $datalogin);
if (!$conn_login) {
	//die ("Failed to connect to MySQL: " . mysqli_connect_error());
	printf("Connect failed: %s\n", mysqli_connect_error());
	exit();
}else{
	//echo "ok2"; 
	$_SESSION["conn_login"]="1";
}


/*
//connect server AX
$server = '192.168.16.6';
// Connect to MSSQL
//$conn_mssql = mssql_connect($server, 'sa', 'Future123');
$conn_mssql = mssql_connect($server, 'sa', 'samanhudi.1');
if (!$conn_mssql) {
    echo 'Something went wrong while connecting to MSSQL AX SERVER';
}else{
	// Select the database 'php'
	$database='MICROSOFTDYNAMICSAX';
	mssql_select_db($database, $conn_mssql) or die("Error conecting Server AX=> ".$database); 
	$_SESSION["conn_mssql"]="1";
}
//atau
//connect server AX mode PDO => set php.ini => php_pdo_mssql aktif
/*
try{
  //$pdo_mssql=new pdo("mssql:host=192.168.16.1;dbname=MICROSOFTDYNAMICSAX","sa","Future123");
	$pdo_mssql=new pdo("mssql:host=192.168.16.6;dbname=MICROSOFTDYNAMICSAX","sa","samanhudi.1");
}
catch(PDOException $e){
	echo $e->getMessage();
	die();
}
*/

/*
Ada 3 koneksi
-------------
$conn_oci
$conn_db2
$conn_mysql
$conn_mssql
*/
?>