me_here
me_here

Reputation: 171

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:

$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. Is this possible?

Upvotes: 0

Views: 1688

Answers (1)

cletus
cletus

Reputation: 625465

Have you tried examining the results of oci_error()?

I haven't used Oracle with PHP (sadly) but the MySQL the general pattern is:

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

It seems logical that the Oracle pattern would be:

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

Upvotes: 1

Related Questions