Langkah pertama, aktifkan dahulu modul php_oci di PHP / XAMPP, langkahnya ada di tulisan sebelumnya.
Koneksi ke database Oracle
<?php
$c = oci_connect("hr", "hr", "192.168.4.15/XE");
?>
Menampilkan data dari Database Oracle
<table width="1000" border="0" cellspacing="2" cellpadding="3">
<tr class="styletable">
<td align="center" valign="top" bgcolor="#DDE748"><span class="styletable">No</td>
<td align="center" valign="top" bgcolor="#DDE748"><span class="styletable">No. RM</td>
<td align="center" valign="top" bgcolor="#DDE748"><span class="styletable">Nama</td>
<td align="center" valign="top" bgcolor="#DDE748"><span class="styletable">Action</td>
</tr>
<?php
$c = oci_connect("hr", "hr", "192.168.4.15/XE");
$s = oci_parse($c, "select * from PASIEN order by NO_RM");
oci_execute($s, OCI_DEFAULT);
$i=0;
while (oci_fetch($s))
{
$i++;
?>
<tr class="styletable">
<td align="left" valign="top" bgcolor="#F9FBE3"><?php echo $i; ?></td>
<td align="left" valign="top" bgcolor="#F9FBE3"><?php echo oci_result($s, "NO_RM"); ?></td>
<td align="left" valign="top" bgcolor="#F9FBE3"><?php echo oci_result($s, "NAMA"); ?></td>
<td align="left" valign="top" bgcolor="#F9FBE3"><a href="edit_pasien.php?NO_RM=<?php echo oci_result($s, "NO_RM"); ?>">edit</a></a> <a href="delete_pasien.php?NO_RM=<?php echo oci_result($s, "NO_RM"); ?>">Delete</a></td>
</tr>
<?php
}
?>
</table>
Menambah data ke database Oracle :
<?php
if ($_POST['submit'])
{
$c = oci_connect("hr", "hr", "192.168.4.15/XE");
$stid = oci_parse($c, "insert into PASIEN (NO_RM, NAMA) values (:NO_RM, :NAMA)");
$NO_RM = $_POST['NO_RM'];
$NAMA = $_POST['NAMA'];
oci_bind_by_name($stid, ":NO_RM", $NO_RM);
oci_bind_by_name($stid, ":NAMA", $NAMA);
oci_execute($stid);
header("location:data_pasien.php");
}
?>
Mengedit / mengupdate data ke database Oracle :
<?php
if ($_POST['submit'])
{
$c = oci_connect("hr", "hr", "192.168.4.15/XE");
$stid = oci_parse($c, "UPDATE PASIEN SET NO_RM=:NO_RM, NAMA=:NAMA WHERE NO_RM=:NO_RM_LAMA");
$NO_RM = $_POST['NO_RM'];
$NAMA = $_POST['NAMA'];
$NO_RM_LAMA = $_POST['NO_RM_LAMA'];
oci_bind_by_name($stid, ":NO_RM", $NO_RM);
oci_bind_by_name($stid, ":NAMA", $NAMA);
oci_bind_by_name($stid, ":NO_RM_LAMA", $NO_RM_LAMA);
oci_execute($stid);
header("location:data_pasien.php");
}
?>
Menghapus data di database Oracle :
<?php
$c = oci_connect("hr", "hr", "192.168.4.15/XE");
$stid = oci_parse($c, "delete from PASIEN where NO_RM=:NO_RM");
$NO_RM = $_GET['NO_RM'];
oci_bind_by_name($stid, ":NO_RM", $NO_RM);
oci_execute($stid);
header("location:data_pasien.php");
?>