1、下載instantclient_12_1,php與ORACLE的動(dòng)態(tài)鏈接庫。地址: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 上面分號,oracle11g去掉 extension=php_oci8_11g.dll前面分號,重啟WEB服務(wù)器。 5、以下是測試用的PHP內容。如果采用oracle默認安裝,則字符集為:ZHS16GBK,所以PHP文件保存時(shí)采用gbk或ansi編碼保存文件,否則會(huì )出現中文亂碼。 putenv("NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK"); $c1 = oci_connect("用戶(hù)名", "密碼", '//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.
電話(huà):0355-3728808 傳真:0355-3728808
ICP備案號:晉ICP備06003721號本站已通過(guò)國際W3C認證
關(guān)鍵字:中聯(lián)科創(chuàng ),長(cháng)治網(wǎng)站建設,長(cháng)治網(wǎng)站推廣,長(cháng)治網(wǎng)絡(luò )工程,長(cháng)治軟件開(kāi)發(fā),山西網(wǎng)站建設,山西軟件開(kāi)發(fā) 長(cháng)治五金網(wǎng)