1,、下載instantclient_12_1,,php與ORACLE的動(dòng)態(tài)鏈接庫(kù)。地址:http://www.oracle.com/technetwork/topics/winsoft-085727.html 選擇最新版下載即可,。 2,、下載后解壓到d:\app\instantclient_12_1 3、在環(huán)境變量PATH中添加d:\app\instantclient_12_1 4,、修改php.ini配置文件,,oracle8去掉extension=php_oci8.dll 上面分號(hào),oracle11g去掉 extension=php_oci8_11g.dll前面分號(hào),重啟WEB服務(wù)器。 5,、以下是測(cè)試用的PHP內(nèi)容,。如果采用oracle默認(rèn)安裝,則字符集為:ZHS16GBK,,所以PHP文件保存時(shí)采用gbk或ansi編碼保存文件,,否則會(huì)出現(xiàn)中文亂碼。 putenv("NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK"); $c1 = oci_connect("用戶名", "密碼", '//localhost:1521/orcl'); function create_table($conn) { $stmt = oci_parse($conn, "create table czehr.hallo (test varchar2(64))"); oci_execute($stmt); echo $conn . " created table "; } function select_data($conn) { $stmt = oci_parse($conn, "select * from czehr.hallo"); oci_execute($stmt, OCI_DEFAULT); echo $conn."----selecting "; while (oci_fetch($stmt)) { echo $conn . " [" . oci_result($stmt, "TEST") . "] "; } echo $conn . "----done "; } function insert_data($conn) { putenv("NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK"); $stmt = oci_parse($conn, "INSERT INTO CZEHR.HALLO (TEST) VALUES ('山西中聯(lián)科創(chuàng)科技有限公司')"); oci_execute($stmt, OCI_DEFAULT); echo $conn . " inserted hallo "; } function commit($conn) { oci_commit($conn); echo $conn . " committed "; } function rollback($conn) { oci_rollback($conn); echo $conn . " rollback "; } create_table($c1); insert_data($c1); // Insert a row using c2 commit($c1); // Commit using c2 select_data($c1);
顯示成功,,則表示鏈接正常,。 |
2006-2014 IT0355.com 山西中聯(lián)科創(chuàng)科技有限公司. All Rights Reserved.
電話:0355-3728808 傳真:0355-3728808
ICP備案號(hào):晉ICP備06003721號(hào)本站已通過(guò)國(guó)際W3C認(rèn)證
關(guān)鍵字:中聯(lián)科創(chuàng),長(zhǎng)治網(wǎng)站建設(shè),,長(zhǎng)治網(wǎng)站推廣,,長(zhǎng)治網(wǎng)絡(luò)工程,長(zhǎng)治軟件開(kāi)發(fā),,山西網(wǎng)站建設(shè),,山西軟件開(kāi)發(fā) 長(zhǎng)治五金網(wǎng)