PHP 8.5.0 Beta 1 available for testing

Voting

: min(one, six)?
(Example: nine)

The Note You're Voting On

php at jaggard dot org dot uk
16 years ago
[Editor's note: OCI8 1.3 should not experience the problem described in this user comment. The first use of such a connection will return an Oracle error which will trigger a cleanup in PHP. Subsequent persistent connection calls will then succeed. For high availability you might consider doing consecutive oci_pconnect calls in your script.]

If you connect using oci_pconnect and the connection has logged you off but is still valid, there seems to be no way to re-use that connection. The next time I try oci_pconnect and then perform an oci_execute operation, I get a "ORA-01012: not logged on" warning. This problem remains, even if I close the connection using oci_close. I ended up with the following (rather annoying) code.

<?php
function getOracleConnection()
{
if (!
function_exists('oci_pconnect'))
return
false;
$toReturn = oci_pconnect('user', 'pass', 'db');
if (
$testRes = @oci_parse($toReturn, 'SELECT Count(group_type_code) FROM pvo.group_type'))
if (@
oci_execute($testRes))
if (@
oci_fetch_array($testRes))
return
$toReturn;
oci_close($toReturn);
if (!
function_exists('oci_connect'))
return
false;
$toReturn = oci_connect('user', 'pass', 'db');
if (
$testRes = @oci_parse($toReturn, 'SELECT Count(group_type_code) FROM pvo.group_type'))
if (@
oci_execute($testRes))
if (@
oci_fetch_array($testRes))
return
$toReturn;
oci_close($toReturn);
if (!
function_exists('oci_new_connect'))
return
false;
$toReturn = oci_new_connect('user', 'pass', 'db');
if (
$testRes = @oci_parse($toReturn, 'SELECT Count(group_type_code) FROM pvo.group_type'))
if (@
oci_execute($testRes))
if (@
oci_fetch_array($testRes))
return
$toReturn;
oci_close($toReturn);
return
false;
}
?>

<< Back to user notes page

To Top