|
Posted by Mladen Gogala on 11/18/14 11:40
On Mon, 20 Feb 2006 13:16:46 +0100, Keith E. Sauvant wrote:
>
> A behaviour we don't understand:
Who is "we"?
>
> +++
> $user = 'xxx';
> $password = 'xxx';
> $database = 'xxx.xxx';
>
> $query = 'SELECT 1 FROM DUAL';
> $link = OCIlogon($user, $password, $database);
>
> //$parse = OCIParse($link, $query);
> unset($link);
Why would do that? Unset will call the destructor and will
log you out of the database? Are you trying to log in for
each SQL statement?
>
> $link = OCIlogon($user, $password, $database);
> $parse = OCIParse($link, $query);
> +++
> -> "... is not a valid oci8 connection resource"
>
> Everything works fine if the first line with $parse is not
> commented out. Everything also works fine if we do not
> unset $link.
>
> This behaviour occurs with ocilogon(), not with
> either ociplogon() or ocinlogon().
>
> Tested with PHP 4.3.11 on Linux, Apache 1.3.33 and Apache
> 1.3.34, OCI PECL extension 1.1.1, Oracle 10.2.01 and
> 10.1.0.3.
>
> Best regards
> Keith
I would have written that like this:
$link = OCIlogon($user, $password, $database);
if (!$link) {
$err=oci_error();
die("General Protection Fault:$err<br>\n");
}
$handle1 = OCIParse($link, $query1);
$handle2 = OCIParse($link, $query2);
/* Note that checking for errors makes no sense as oracle
does error checking only when it attempts to execute
the cursor. */
oci_execute($handle1);
$err=oci_error($link);
if ($err) die("General Protection Fault:$err<br>\n");
oci_execute($handle2);
$err=oci_error($link);
if ($err) die("General Protection Fault:$err<br>\n");
Note that error checking is necessary after each statement as neither OCI8
nor PHP4 support exceptions. I wholeheartedly recommend switching to PHP5
as it is stable enough for production and makes the life of poor
programmer much, much easier.
--
http://www.mgogala.com
Navigation:
[Reply to this message]
|