How under Windows PHP7 / 5.6 or later connect Oracle 12c, and use the PDO

https://blog.csdn.net/houpanqi/article/details/78841928

 

First of all, the main focus of this article is: in Win platform, how to use PHP7 connect Oracle 12C, so the installation and configuration of Oracle, please Baidu own or Google.

According to this tutorial, basically solve the problem of connecting the majority of Oracle being given!

Preparation: (64, for example, all the required tools, documentation, no special instructions, should be 64, and the version number to correspond exactly, otherwise unknown variety of errors that may occur)
1, installed and configured Oracle 12C.
2, PhpStudy for example, as in other LAMP tool works.
3, Oracle Instant Client version of the official correspondence. Recommended to download Basic.
4, strict correspondence PHP version number (such as 7.0.21) three dll files: php_pdo_oci.dll, php_oci8_12c.dll, php_oci8.dll

Well, that is entered, the following start configuring, make a successful connection PHP Oracle.
1. Open the PHP extension, php_pdo_oci.dll, php_oci8_12c.dll, php_oci8.dll three have open.
And then view the phpinfo

 

The route marked on the map, copy down.
Open CMD execute: mkdir c: \ php-sdk \ oracle \ x64 \ instantclient_12_1 \ sdk, built directory.
 
2, will be ready Instant Client decompress it, then put all the files in the root directory, copy it to build the above-sdk directory. (important)
 

3、创建环境变量
Path中,增加 C:\php-sdk\oracle\x64\instantclient_12_1\sdk
ORACLE_HOME = C:\php-sdk\oracle\x64\instantclient_12_1\sdk
TNS_ADMIN = C:\php-sdk\oracle\x64\instantclient_12_1\sdk

4、拷贝文件:
1> 将C:\php-sdk\oracle\x64\instantclient_12_1\sdk 目录下的文件,拷贝到Apache的bin目录
2> 同样,将上述文件,拷贝到 PHP的根目录下。

重启Apache服务即可。

以Yii2为例:

配置好DSN后,测试查询,一切正常:

 

至此,教程结束。
 
注:如果此时还不行,那就要将C:\php-sdk\oracle\x64\instantclient_12_1\sdk下的文件,拷贝致windows/sysWoW64下(32位的在system32下)
 

 

Guess you like

Origin www.cnblogs.com/achengmu/p/11961577.html
Recommended