老熟女激烈的高潮_日韩一级黄色录像_亚洲1区2区3区视频_精品少妇一区二区三区在线播放_国产欧美日产久久_午夜福利精品导航凹凸

怎么用PHP連接Oracle數(shù)據(jù)庫(kù)

這篇文章主要講解了“怎么用PHP連接Oracle數(shù)據(jù)庫(kù)”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“怎么用PHP連接Oracle數(shù)據(jù)庫(kù)”吧!

創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供鹿泉網(wǎng)站建設(shè)、鹿泉做網(wǎng)站、鹿泉網(wǎng)站設(shè)計(jì)、鹿泉網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)與制作、鹿泉企業(yè)網(wǎng)站模板建站服務(wù),十年鹿泉做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。

連接

< ?if($conn=Ora_Logon("user@TNSNAME","password"))   {echo"SUCCESS!Connectedtodatabase\n";   }else   {echo"Failed:-(Couldnotconnecttodatabase\n";}   Ora_Logoff($conn);   phpinfo();   ?>

以上代碼使用TNSNAME(在你的tnsnames.ora文件中指明)定義的Oracle數(shù)據(jù)庫(kù)名稱、用戶名稱和密碼連接數(shù)據(jù)庫(kù)。在成功連接的基礎(chǔ)上,ora_logon函數(shù)返回一個(gè)非零的連接ID并儲(chǔ)存在變量$conn中。

查詢

假設(shè)與數(shù)據(jù)庫(kù)已經(jīng)連接就緒,下面我們就來(lái)實(shí)際的應(yīng)用對(duì)數(shù)據(jù)庫(kù)的查詢。下面的代碼演示了一個(gè)連接并查詢的典型例子:

functionprintoraerr($in_cur)

{

//檢查Oracle是否出錯(cuò)

//如果存在錯(cuò)誤則顯示

//當(dāng)指針被激活時(shí)每次請(qǐng)求Oracle后調(diào)用該函數(shù)

if(ora_errorcode($in_cur))

echo"Oraclecode-".ora_error($in_cur)."\n";

return;

}

if(!($conn=ora_logon("user@TNSNAME","password")))

{echo"Connectiontodatabasefailed\n";

exit;

}

echo"Connectedasconnection-$conn\n";

echo"Openingcursor...\n";

$cursor=ora_open($conn);printoraerr($cursor);

echo"Openedcursor-$cursor\n";

$qry="selectuser,sysdatefromdual";

echo"Parsingthequery$qry...\n";

ora_parse($cursor,$qry,0);printoraerr($cursor);

echo"Queryparsed\n";

echo"Executingcursor...\n";

ora_exec($cursor);printoraerr($cursor);

echo"Executedcursor\n";

echo"Fetchingcursor...\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"Fetchedallrecords\n";

echo"Closingcursor...\n";

ora_close($cursor);

echo"Closedcursor\n";

echo"Loggingofffromoracle...\n";

ora_logoff($conn);

echo"Loggedofffromoracle\n";

?>

怎樣用PHP連接Oracle數(shù)據(jù)庫(kù)

顯示結(jié)果

以下代碼演示了怎樣查詢數(shù)據(jù)庫(kù)并將結(jié)果輸出:

functionprintoraerr($in_cur,$conn)

{

//檢查Oracle是否出錯(cuò)

//如果存在錯(cuò)誤則顯示

//當(dāng)指針被激活時(shí)每次請(qǐng)求Oracle后調(diào)用該函數(shù)

//Ifitencounteredanerror,weexitimmediately

if(ora_errorcode($in_cur))

{echo"Oraclecode-".ora_error($in_cur)."n";

ora_logoff($conn);

exit;

}

return;

}

functionexequery($w_qry,$conn)

{

$cursor=ora_open($conn);printoraerr($cursor,$conn);

ora_parse($cursor,$w_qry,0);printoraerr($cursor,$conn);

ora_exec($cursor);printoraerr($cursor,$conn);

$numrows=0;

$w_numcols=ora_numcols($cursor);

//顯示頭部

echo"\n";

for($i=0;$i<$w_numcols;$i++)   {   $align=(ora_columntype($cursor,$i)=="NUMBER")?"RIGHT":"LEFT";   echo"\t".ora_columnname($cursor,$i)."\n";   }   echo"\n";   while(ora_fetch($cursor))   {   echo"\n";   for($i=0;$i<$w_numcols;$i++) align="(ora_columntype($cursor,$i)=="NUMBER")?"RIGHT":"LEFT";" .="" else="" numrows="=0)" conn="ora_logon("user@SID","password")))" qry="SELECT   deptno\" from="" employee="">

基于HTTP的Oracle登錄

將以下代碼加在PHP頁(yè)面代碼之前以確認(rèn)Oracle登錄。注意你必須正確設(shè)定$SID。

if(!isset($PHP_AUTH_USER))

{

Header("WWW-authenticate:basicrealm=\"$SID\"");

Header("HTTP/1.0401Unauthorized");

$title="LoginInstructions";

echo"

Youarenotauthorizedtoenterthesite

\n";

exit;

}

else

{

if(!($conn=ora_logon("$PHP_AUTH_USER@$SID",$PHP_AUTH_PW)))

{Header("WWW-authenticate:basicrealm=\"$SID\"");

Header("HTTP/1.0401Unauthorized");

$title="LoginInstructions";

echo"

Youarenotauthorisedtoenterthesite

\n";

exit;

}}

?>

感謝各位的閱讀,以上就是“怎么用PHP連接Oracle數(shù)據(jù)庫(kù)”的內(nèi)容了,經(jīng)過(guò)本文的學(xué)習(xí)后,相信大家對(duì)怎么用PHP連接Oracle數(shù)據(jù)庫(kù)這一問(wèn)題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!


網(wǎng)站標(biāo)題:怎么用PHP連接Oracle數(shù)據(jù)庫(kù)
網(wǎng)頁(yè)地址:http://www.xueling.net.cn/article/gdojpo.html

其他資訊

在線咨詢
服務(wù)熱線
服務(wù)熱線:028-86922220
TOP
主站蜘蛛池模板: 亚洲国产成人精品无码区二本 | 日本xxx在线播放 | 国产日韩欧美色 | 久久精品国产99久久6动漫亮点 | 日韩精品人妻系列无码专区 | 国产黄片视频在线看 | 在线观看片免费人成视频播放 | 无套内射chinesehd熟女 | 国产精品亚洲第一区二区三区 | a在线视频播放观看免费观看 | 人禽伦免费交视频播放 | 午夜无码无遮挡在线视频 | 成人免费视频视频在线观看免费 | 成年人免费小视频 | 91福利区 | 麻豆久久久久久 | 日本xxxx片免费观看 | av中文字幕无码免费看 | 国产目拍亚洲精品一区二区 | 久久久毛片视频 | 99久久婷婷国产综合精品青草免费 | 亚洲成网站 | 精品久久成人 | 亚洲美女免费视频 | 国产原创AV在线播放不卡 | 美女视频很黄很a免费 | 亚洲欧洲一区二区三区在线 | 亚洲AV无码成人影片在线观看 | 国产片一区二区 | 黄色小说视频网站 | 国产最新精品亚洲2024不卡 | 人成午夜大片免费视频 | 无码任你躁久久久久久老妇 | av在线播放中字 | 亚洲成成品网站 | 伊人久久精品无码二区麻豆 | 99久久一区二区三区 | 777亚洲欧美日韩精品中文中字幕 | 一色桃子中文字幕人妻熟女作品 | 久久精品国产亚州Av果冻传媒 | 岛国一级片 |