PHP如何配置Oracle 10g 数据库,并且如何连接数据库?
发布网友
发布时间:2022-04-29 09:16
我来回答
共2个回答
热心网友
时间:2022-04-09 05:45
<?php
$db="
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = my11g)
)
)";
//$conn = oci_pconnect("sys", "123456", $db);
$conn = oci_pconnect("scott", "tiger", $db);
//$conn = ora_logon ( "scott@my11g", "tiger" );
if (!$conn) {
$e = oci_error();
print htmlentities($e['message']);
// exit;
$e1 = ocierror();
echo "失败!";
//print htmlentities($e1['message']);
exit;
}
$query = 'select * from emp';
$stid = oci_parse($conn, $query);
if (!$stid) {
$e = oci_error($conn);
print htmlentities($e['message']);
exit;
}
$r = oci_execute($stid, OCI_DEFAULT);
if(!$r) {
$e = oci_error($stid);
echo htmlentities($e['message']);
exit;
}
print '<table border="1">';
while($row = oci_fetch_all($stid, $array)) {
//while($row = ora_fetch($stid, OCI_RETURN_NULLS)) {
print '<tr>';
//foreach($row as $item) {
//print '<td>'.($item?htmlentities($item):' ').'</td>';
echo "$array";
//}
print '</tr>';
}
print '</table>';
oci_close($conn);
?>
热心网友
时间:2022-04-09 07:03
php有链接oracle 的链接函数,安装函数的参数提供数据库信息就可以
详细可以参考php帮助手册