Skip to content

Instantly share code, notes, and snippets.

@hidayat365
Created April 10, 2012 06:43
Show Gist options
  • Save hidayat365/2348855 to your computer and use it in GitHub Desktop.
Save hidayat365/2348855 to your computer and use it in GitHub Desktop.
Sample PHP code for Oracle Database v2
<?php
// connect ke oracle xe pakai easy naming
$conn = oci_connect('hr', 'hr', '//localhost/xe');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
// execute query
$stid = oci_parse($conn, 'select * from employees where 1=0');
oci_execute($stid);
// tampilkan data
echo "<table border='1'>\n";
$row = oci_fetch_assoc($stid);
if(!$row) {
echo 'no result found!';
}
else {
do {
echo "<tr>\n";
foreach ($row as $item) {
echo " <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : "&nbsp;") . "</td>\n";
}
echo "</tr>\n";
} while ($row=oci_fetch_assoc($stid));
}
echo "</table>\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment