- 时间:2020-06-16 18:42 编辑: 来源: 阅读:
- 扫一扫,手机访问
摘要:Win7 64位系统下PHP连接Oracle数据库
下面讲下配置过程
一、下载oracle instantclient
下载地址:[url=http://www.oracle.com/technetwork/topics/winx64soft-089540.html]http://www.oracle.com/technetwork/topics/winx64soft-089540.html[/url]
下载 instantclient-basic-windows.x64-11.2.0.4.0
解压路径:D:\Program Files (x86)\Oracle64Client\instantclient_11_2
*注:客户端需要对应数据库版本。
二、配置系统环境变量
在PATH环境变量后加入:;D:\Program Files (x86)\Oracle64Client\instantclient_11_2
三、配置PHP支持OCI扩展
修改配置文件php.ini
开启配置如下
[img]http://files.jb51.net/file_images/article/201408/2014820102818588.png?2014720102828[/img]
四、重启Apache服务测试
使用探针函数phpinfo()查看扩展是否开启,如果出现下图说明扩展开启
[img]http://files.jb51.net/file_images/article/201408/2014820102840951.png?2014720102849[/img]
五、测试数据库连接
在站点根目录编写oracle.php,我连接的是虚拟机CentOS中的Oralce数据库
代码如下:
<?php
$conn = ocilogon('test','test','192.168.23.131:1521/dev');
if (!$conn)
{
$Error = oci_error();
print htmlentities($Error['message']);
exit;
}
else
{
echo "Connected Oracle Successd!"."<br>";
ocilogoff($conn);
}
?>
浏览器地址栏输入 [url=http://localhost/oracle.php]http://localhost/oracle.php[/url]
显示Connected Oracle Successd!说明数据库连接成功。