问题描述
我安装了oracle 11g,并确实创建了一些表并使用sql developer对其进行了操作,我正在寻找一种在托管站点上将oracle与php连接的方法.
I installed oracle 11g and I did create some tables and manipulate it using sql developer, and I am looking for a way to connect oracle with php on hosting site.
我尝试过,但是使用此代码后出现错误:
I tried but I get error after using this code:
$Conexion_ID =oci_connect($OracleUser, $OraclePassw, $OracleIP);
这是错误:
Call to undefined function oci_connect()
我知道我应该安装和配置OCI8,所以我下载了此文件:
I've known that I should install and configure OCI8, so I downloaded this file:
http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
但是我不知道我应该在哪个文件夹中使连接正常工作.
but I don't know in which folder should I them to make the connection work well.
推荐答案
从此处下载PHP扩展(确认PHP版本并下载相同的线程安全[TS]版本): http://pecl.php.net/package/oci8/2.0.8/Windows
Download the PHP Extension from here(Confirm the PHP Version and download for the same, the thread safe[TS] version):http://pecl.php.net/package/oci8/2.0.8/windows
您应该能够找到三个.dll
You should be able to find three .dll's
php_oci8.dll,php_oci8_11g.dll和php_oci8_12c.dll
php_oci8.dll, php_oci8_11g.dll and php_oci8_12c.dll
将所有dll放在扩展目录中,在WAMP中通常为wamp\bin\php\php5.*.*\ext
Place all dll's in extension directory, in WAMP it is generally wamp\bin\php\php5.*.*\ext
从wamp服务器的系统尝试中打开php配置,并添加以下行:
open the php configuration from the System try of wamp server and add the line:
; Enable only which is required
;extension=php_oci8.dll
extension=php_oci8_11g.dll
;extension=php_oci8_12c.dll
重新启动Apache服务器.
Restart the Apache server.
编辑:抱歉,我认为其他dll是库,但它们分别用于不同的oracle版本.您可以启用11g.答案已更新.
EDIT : Sorry I thought the other dll's are the libraries, but instead they are for different oracle versions. In your case enable 11g. Answer updated.
更新2016-11-07 :只是想说最新的软件包可以在这里找到 https://pecl.php.net/package/oci8 .我猜我写这个答案的时候是最新的2.0.8.
Update 2016-11-07: just wanted to say that latest package can be found here https://pecl.php.net/package/oci8. When I wrote this answer 2.0.8 was latest i guess.
这篇关于安装和配置OCI8以将oracle连接到php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!