phpé
ç½®oracleé常çç®åéå§php.iniæ件ä¸çé
ç½®,å»æ ;extention = php_oci8.dll,å»æåé¢çåå·,éå¯apacheå°±å¯ä»¥äº
oracleæ°æ®åºå»ºç«é¾æ¥,代ç å¦ä¸:
1ï¼
$conn =
oci_connect('username','password',"(DEscriptION=(ADDRESS=(PROTOCOL
=TCP)(HOST=192.168.1.100)(PORT = 1521))(CONNECT_DATA =(SID=test)))");
2ï¼
$conn = oci_connect('username','password','192.168.1.100/test');
3.Oracle è¿æ¥æ¹æ³
set adocon=Server.Createobject("adodb.connection")
adocon.open"Driver={microsoft odbc for oracle};server=oraclesever.world;uid=admin;pwd=pass;"
å®æ´çä¾åå¦ä¸ï¼
<?php
$conn = oci_connect('hr', 'hr', 'orcl'); // 建ç«è¿æ¥
if (!$conn) {
$e = oci_error();
print htmlentities($e['message']);
exit;
}
$query = 'SELECT * FROM DEPARTMENTS'; // æ¥è¯¢è¯å¥
$stid = oci_parse($conn, $query); // é
ç½®SQLè¯å¥ï¼åå¤æ§è¡
if (!$stid) {
$e = oci_error($conn);
print htmlentities($e['message']);
exit;
}
$r = oci_execute($stid, OCI_DEFAULT); // æ§è¡SQLãOCI_DEFAULT表示ä¸è¦èªå¨commit
if(!$r) {
$e = oci_error($stid);
echo htmlentities($e['message']);
exit;
}
// æå°æ§è¡ç»æ
print '<table border="1">';
while($row = oci_fetch_array($stid, OCI_RETURN_NULLS)) {
print '<tr>';
foreach($row as $item) {
print '<td>'.($item?htmlentities($item):' ').'</td>';
}
print '</tr>';
}
print '</table>';
oci_close($conn);
?>
温馨提示:答案为网友推荐,仅供参考