简体   繁体   English

使用PHP函数oci_connect获取ORA Oracle错误代码?

[英]Getting ORA Oracle error code using PHP function oci_connect?

The PHP function oci_connect (which connects to an Oracle database) just returns false if it fails, which at the moment I handle like this: 如果失败,PHP函数oci_connect(连接到Oracle数据库)将返回false,此刻我将按照以下方式进行处理:

$connection = oci_connect($username, $password, $database);
if (!$connection){
    return $result = "Trouble connecting to the Oracle Database";
}

But really I'd like to have the actual ORA error code, so I can be more informative. 但实际上我想拥有实际的ORA错误代码,因此我可以提供更多信息。 Is this possible? 这可能吗?

Have you tried examining the results of oci_error() ? 您是否尝试过检查oci_error()的结果?

I haven't used Oracle with PHP (sadly) but the MySQL the general pattern is: 我还没有将Oracle与PHP结合使用(可悲的是),但是MySQL的一般模式是:

if (!mysql_connect(...)) {
  error_log('Error connecting: ' . mysql_error()); // or just die
}

It seems logical that the Oracle pattern would be: Oracle模式将是合理的:

if (!oci_connect(...)) {
  error_log('Error connecting: ' . oci_error());
}

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

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