Created
April 10, 2012 04:52
-
-
Save hidayat365/2348400 to your computer and use it in GitHub Desktop.
Sample PHP code for Oracle Database
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'); | |
oci_execute($stid); | |
// tampilkan data | |
echo "<table border='1'>\n"; | |
while ($row = oci_fetch_assoc($stid)) { | |
echo "<tr>\n"; | |
foreach ($row as $item) { | |
echo " <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : " ") . "</td>\n"; | |
} | |
echo "</tr>\n"; | |
} | |
echo "</table>\n"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment