Home  >  Article  >  Database  >  Linux下使用PHP远程连接Oracle

Linux下使用PHP远程连接Oracle

WBOY
WBOYOriginal
2016-06-07 17:35:39960browse

PHP远程连接Oracle需要OCI包,这个包由oracle提供,可以直接安装Oracle的InstantClient来得到这个包

PHP远程连接Oracle需要OCI包,这个包由oracle提供,可以直接安装Oracle的InstantClient来得到这个包
下载地址

安装很简单
rpm -Uvh oracle-instantclient-basic-10.2.0.3-1.i386.rpm
rpm -Uvh oracle-instantclient-devel-10.2.0.3-1.i386.rpm

安装完成后,可以在/usr/lib/oracle 看到安装的库文件

之后需要重新编译php,加上--with-oci8=share,instantclient,/usr/lib/oracle/10.2.0.3/client/lib参数,如下:
./configure --with-mysql --with-apxs2=/usr/local/apache2/bin/apxs--with-oci8=share,instantclient,/usr/lib/oracle/10.2.0.3/client/lib

测试代码:

$conn = OCILogon('username','password','192.168.1.2/test');
if (!$conn) {
$e = oci_error();
print htmlentities($e['message']);
exit;
}
else
{
echo "Successfully connected to Oracle!\n";
        ocilogoff($conn);
}
?>

一些相关链接:

还有就是php中oci的编译参数,可以看php原代码目录中ext/oci8的README,,里面有解释。

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn