如何从php连接到Oracle DB 12c?
问题描述:
我正在使用XAMPP v3.2.2,并且试图从PHP连接到Oracle数据库12c.
I am using XAMPP v3.2.2 and I am trying to connect from PHP to Oracle database 12c.
我已经注释掉了php.ini中的扩展名php_oci8_12c.dll
,重新启动了Apache,并安装了32bit的Oracle Instantclient_12_2.
I have already commented out the extension php_oci8_12c.dll
in php.ini, restarted Apache, and installed Oracle instantclient_12_2 32bit.
但是,我遇到此错误:
致命错误:未捕获错误:调用未定义函数oci_connect()
Fatal error: Uncaught Error: Call to undefined function oci_connect()
答
遵循有关XAMPP v3.2.2和Oracle数据库12c配置的说明.
Follow instructions for XAMPP v3.2.2 and Oracle database 12c config.
- 下载Instantclient_12_2并解压缩到c:\ instantclient_12_2(确保您的xamp和Instantclient都是相同的x86或64位体系结构)
- 在任何oracle目录之前为c:\ instantclient_12_2设置环境路径.重新启动电脑
- 从 http://pecl.php.net/package下载oci8 dll /oci8/2.0.6/windows
- 从上面的链接中选择5.5线程安全(TS)x64
- 解压缩所有文件并将其复制到c:/xampp/php/ext目录
- 打开php.ini,删除(;)扩展名= php_oci8.dll,扩展名= php_oci8_12c.dll并保存
- 重新启动apache
- 查看phpinfo并搜索oci8模块(如果已找到并启用),然后确定.
- 使用php oracle连接脚本进行测试.
- Download instantclient_12_2 and unzip to c:\instantclient_12_2 (make sure your xamp and instantclient both are same architechture x86 or 64-bit)
- setup ENVIRONMENT PATH for c:\instantclient_12_2 before any oracle directory. Restart PC
- download oci8 dll from http://pecl.php.net/package/oci8/2.0.6/windows
- select 5.5 Thread Safe (TS) x64 from above link
- unzip and copy all files to c:/xampp/php/ext directory
- open php.ini remove (;) for extension=php_oci8.dll, extension=php_oci8_12c.dll and save it
- restart apache
- look phpinfo and search for oci8 module if found and enabled then ok.
- test with php oracle connection script .