php7 无法连接到 oracle 池连接

php7 cannot connect to oracle pooled connection

这在 cli 和非池连接上工作正常。当我在 cli 上尝试以下操作时它有效

sqlplus CCP/"***"@DECCP1ST_POOLED.test.vis

但是当我尝试在 php 中执行此操作时,它会抛出错误

$c = oci_connect('CCP', "***", 'domain.com:33001/DECCP1ST_POOLED.test.vis');
print_r($c);

输出是

Warning: oci_connect(): ORA-12514: TNS:listener does not currently know of service requested in connect descriptor in

在我的 tnsnames.ora 我有

DECCP1ST_POOLED.test.vis =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = domain.com)(PORT = 33001))
    (CONNECT_DATA =
      (SERVER = POOLED)
      (SERVICE_NAME = DECCP1ST.test.vis)
    )
  )

我已经关注了这个pdf。我设置了 oci8.connection_class = SHARED

根据您在问题中链接的 PDF,第 15 页:

PHP applications must specify the server type POOLED in the connect string to use DRCP. Using Oracle’s Easy Connect syntax, the PHP call to connect to the sales database on myhost would look like:

$c = oci_pconnect('myuser', 'mypassword', 'myhost/sales:POOLED');

基于以上内容和您的 TNS 字符串,您需要在脚本中使用以下内容:

$c = oci_connect('CCP', '***', 'domain.com:33001/DECCP1ST.test.vis:POOLED');

请务必注意,您在这里使用的是 Easy Connect 语法,因此 TNSNAMES.ORA 文件将被忽略。因此,您必须使用定义的 SERVICE_NAME (DECCP1ST.test.vis) 而不是 TNS 别名 (DECCP1ST_POOLED.test.vis)!