phporacle資料庫
⑴ php,pdo怎麼連接oracle資料庫
php有強來大的功能不但可以自支持mysql,mssql,mysqli之個我們還可以與oracle數據連接,要讓php支持oracle非常的簡單我們只要把php.ini中的;extention = php_oci8.dll分號去掉即可.
請先安裝oracle的客戶端,能夠用客戶端訪問oracle。
php支持oracle連接函數
php.ini文件中的配置,去掉 ;extention = php_oci8.dll,去掉前面的分號,重啟apache就可以了,如果不行,我們再把php目錄中的php_oci8.dll拷到windows系統的system32下面去吧.
oracle資料庫建立鏈接,代碼如下:
$conn=oci_connect('username','password',"(DEscriptION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.100)(PORT=1521))(CONNECT_DATA=(SID=test)))");
⑵ Oracle 資料庫 如何連接 php
function printoraerr($in_cur)
{
// 檢查Oracle是否出錯
// 如果存在錯誤則顯示
// 當指針被激活時每次請求Oracle後調用該函數
if(ora_errorcode($in_cur))
echo "Oracle code - ".ora_error($in_cur)."\n";
return;
}
if (!($conn=ora_logon("user@TNSNAME","password")))
{echo "Connection to database failed\n";
exit;
}
echo "Connected as connection - $conn \n";
echo "Opening cursor ... \n";
$cursor=ora_open($conn); printoraerr($cursor);
echo "Opened cursor - $cursor \n";
$qry="select user,sysdate from al";
echo "Parsing the query $qry ... \n";
ora_parse($cursor,$qry,0); printoraerr($cursor);
echo "Query parsed \n";
echo "Executing cursor ... \n";
ora_exec($cursor); printoraerr($cursor);
echo "Executed cursor \n";
echo "Fetching cursor ... \n";
while(ora_fetch($cursor))
{
$user=ora_getcolumn($cursor,0); printoraerr($cursor);
$sysdate=ora_getcolumn($cursor,1); printoraerr($cursor);
echo " row = $user, $sysdate \n";
}
echo "Fetched all records \n";
echo "Closing cursor ... \n";
ora_close($cursor);
echo "Closed cursor \n";
echo "Logging off from oracle... \n";
ora_logoff($conn);
echo "Logged off from oracle \n";
?>
⑶ php 連接oracle資料庫語句怎麼寫
php教程連接oracle資料庫教程代碼
$conn = OCILogon("scott","tiger","你的oracle資料庫名字");
$stmt = OCIParse($conn,"select empno, ename from emp");
OCIDefineByName($stmt,"EMPNO",&$empno);
OCIDefineByName($stmt,"ENAME",&$ename);
OCIExecute($stmt);
while (OCIFetch($stmt)) {
echo "empno:".$empno."n";
echo "ename:".$ename."n";
}
OCIFreeStatement($stmt);
OCILogoff($conn);
⑷ php中怎麼配置支持oracle 11g資料庫
1、安裝oracle 11g client或instantclient 11
2、編譯php支持oracle
--with-oci8[=DIR]
--with-pdo-oci[=DIR]
3、配置php.ini支持oracle 11g
windows:
extension=php_oci8_11g.dll
linux:參考
http://www.oracle.com/technetwork/articles/technote-php-instant-084410.html
4、ora.php實例
<?php
$conn = oci_connect('user', 'passwd', 'ip:1521/orcl'); // 建立連接
if (!$conn) {
$e = oci_error();
print htmlentities($e['message']);
exit;
}
$query = 'SELECT * FROM account'; // 查詢語句
$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_r($item);
}
print '</tr>';
}
print '</table>';
oci_close($conn);
?>
⑸ PHP中如何查詢oracle資料庫,寫出簡單的例子,謝謝
嘻嘻這個不難但很難說只能給你個思路
ODBC
odbc_connect() 連接方法