note 86253 modified in function.oci-pconnect by sixd
| From: | sixd@php.net | Date: | Mon, 05 Oct 2009 01:17:35 +0000 |
| Subject: | note 86253 modified in function.oci-pconnect by sixd | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-161269@lists.php.net to get a copy of this message | ||
[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;
}
?>
--was--
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;
}
?>
http://php.net/manual/en/function.oci-pconnect.php