简体   繁体   English

如何使用 PHP pdo_oci 扩展连接到 Oracle 19c

[英]How connect to Oracle 19c with PHP pdo_oci extension

How I can connect to Oracle 19c database with PHP pdo_oci extension on the Windows?如何使用 Windows 上的 PHP pdo_oci 扩展连接到 Oracle 19c 数据库?

I have installed Oracle Instant Client 19.0.0, PHP 7.4.4 and Apache 2.4.我已经安装了 Oracle Instant Client 19.0.0、PHP 7.4.4 和 Apache 2.4。 Oracle database is in the other server. Oracle 数据库在另一台服务器中。

I get an error "TNS protocol adapter error" when I want connect with PDO.当我想连接 PDO 时,出现错误“TNS 协议适配器错误”。

Connection via sqlplus is successful in the command line.在命令行中通过 sqlplus 连接成功。

Did you configure your tnsnames.ora?您是否配置了 tnsnames.ora? If not you should create a folder inside the root of your instant client like so:如果不是,您应该在即时客户端的根目录中创建一个文件夹,如下所示:

C:\instantclient_19_9\network\admin

Inside of that folder you should have a file called在该文件夹中,您应该有一个名为

tnsnames.ora

This file must contain your connection data此文件必须包含您的连接数据

    test = 
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = server_name_or_ip_address)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = test)
    )
  )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM