Created
April 10, 2012 06:43
-
-
Save hidayat365/2348855 to your computer and use it in GitHub Desktop.
Sample PHP code for Oracle Database v2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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) : " ") . "</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