<?php
$conn = oci_connect("username", "password", "dbname"); //连接oracle数据库
if (!$conn) {
$e = oci_error();
print htmlentities($e['message']);
exit;
}
$query = 'SELECT * FROM BS order by sj desc'; // 查询语句
$stid = oci_parse($conn, $query);
$r = oci_execute($stid);
// Fetch the results in an associative array
print '<table border="1">';
while ($row = oci_fetch_array($stid, OCI_RETURN_NULLS+OCI_ASSOC)) {
print '<tr>';
foreach ($row as $item) {
print '<td>'.($item?htmlentities($item):' ').'</td>';
}
print '</tr>';
}
print '</table>';
// Close the Oracle connection
oci_close($conn);
?>
$conn = oci_connect("username", "password", "dbname"); //连接oracle数据库
if (!$conn) {
$e = oci_error();
print htmlentities($e['message']);
exit;
}
$query = 'SELECT * FROM BS order by sj desc'; // 查询语句
$stid = oci_parse($conn, $query);
$r = oci_execute($stid);
// Fetch the results in an associative array
print '<table border="1">';
while ($row = oci_fetch_array($stid, OCI_RETURN_NULLS+OCI_ASSOC)) {
print '<tr>';
foreach ($row as $item) {
print '<td>'.($item?htmlentities($item):' ').'</td>';
}
print '</tr>';
}
print '</table>';
// Close the Oracle connection
oci_close($conn);
?>
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/220205/viewspace-2145330/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/220205/viewspace-2145330/
本文展示了一个使用PHP连接并查询Oracle数据库的具体示例。通过示例代码了解如何建立数据库连接、执行SQL查询以及获取结果集。适用于初学者学习PHP与Oracle数据库交互的基本方法。
559

被折叠的 条评论
为什么被折叠?



