php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57632 ocilogon inside function connect more than once
Submitted: 2007-04-24 09:35 UTC Modified: 2007-04-24 10:43 UTC
From: fernandopapa at gmail dot com Assigned:
Status: Not a bug Package: oci8 (PECL)
PHP Version: 4.4.3 OS: RHAS 4, x86_64
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: fernandopapa at gmail dot com
New email:
PHP Version: OS:

 

 [2007-04-24 09:35 UTC] fernandopapa at gmail dot com
Description:
------------
We have two instalations.
The first one, had php 4.4.3 with the standar oci8 support (the oci8 than comes with 4.3.3).

The second, had php 4.4.3 with the latest pecl oci8 package (1.2.3). This because in this installation we need to use oracle instanclient.

The compilation was standalone php (only for scripting purposes, no integration with apache)

We need to run a php script who open a oracle connection inside a php-function (the ocilogon is inside the function). These php-function was called several times (in the test is inside a loop, 10 times). 
When php established the connection, execute a package. In this package, we have a session variable (mantain the value until session is closed).
The test case only sum 1 to the last value of the variable.

In the first installation, the session variable mantain the value until php finish, we print the value of the variable and see 1,2,3,4...10.

In the second installation, the session variable doesn't maintain the value, we print the value of the variable and see 1,1,1,1...1.

I need to know what is the "bad behavior", or what is the problem.

I test one more thing. In the second installation, I made an ocilogon before the loop. And I get the same result of the first installation.

So, I made a workaround, but I want to know what is the problem, if this is a bug, a feature or an incorrect use.



Reproduce code:
---------------
<?php
function testdb($i)
{
   $con = ocilogon("scott","tiger","test");
   echo $i . $con . " -> ";
   $curs = ocinewcursor($con);
   $query = " begin PACK_TRANSFER_V4_NO_TRANSFERIB.PR_PRUEBA_SESSION( :data ); end;";
   $stat  = ociparse($con,$query);
   ocibindbyname($stat,"data",$curs,-1,OCI_B_CURSOR);
   ociexecute($stat);
   ociexecute($curs);
   ocifetch($curs);
   $valor =  ociresult($curs,"CONTADOR") ;
   echo "Valor del CONTADOR: " . $valor . "\n";
 }
print "INICIO\n";
for($i=0;$i<10;$i++)
   testdb($i); 
print "FIN<BR>\n";
?>

Expected result:
----------------
# /usr/local/bin/php test_connection_logon.php
INICIO
0Resource id #4 -> Valor del CONTADOR: 1
1Resource id #7 -> Valor del CONTADOR: 1
2Resource id #10 -> Valor del CONTADOR: 1
3Resource id #13 -> Valor del CONTADOR: 1
4Resource id #16 -> Valor del CONTADOR: 1
5Resource id #19 -> Valor del CONTADOR: 1
6Resource id #22 -> Valor del CONTADOR: 1
7Resource id #25 -> Valor del CONTADOR: 1
8Resource id #28 -> Valor del CONTADOR: 1
9Resource id #31 -> Valor del CONTADOR: 1
FIN<BR>

Actual result:
--------------
# /usr/local/bin/php test_connection_logon.php
INICIO
0Resource id #4 -> Valor del CONTADOR: 1
1Resource id #7 -> Valor del CONTADOR: 2
2Resource id #10 -> Valor del CONTADOR: 3
3Resource id #13 -> Valor del CONTADOR: 4
4Resource id #16 -> Valor del CONTADOR: 5
5Resource id #19 -> Valor del CONTADOR: 6
6Resource id #22 -> Valor del CONTADOR: 7
7Resource id #25 -> Valor del CONTADOR: 8
8Resource id #28 -> Valor del CONTADOR: 9
9Resource id #31 -> Valor del CONTADOR: 10
FIN<BR>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-24 09:40 UTC] fernandopapa at gmail dot com
Sorry, I misunderstand the last two fields.

This is the expected result:
# /usr/local/bin/php test_connection_logon.php
INICIO
0Resource id #4 -> Valor del CONTADOR: 1
1Resource id #7 -> Valor del CONTADOR: 2
2Resource id #10 -> Valor del CONTADOR: 3
3Resource id #13 -> Valor del CONTADOR: 4
4Resource id #16 -> Valor del CONTADOR: 5
5Resource id #19 -> Valor del CONTADOR: 6
6Resource id #22 -> Valor del CONTADOR: 7
7Resource id #25 -> Valor del CONTADOR: 8
8Resource id #28 -> Valor del CONTADOR: 9
9Resource id #31 -> Valor del CONTADOR: 10
FIN<BR>

And this is the actual result:
# /usr/local/bin/php test_connection_logon.php
INICIO
0Resource id #4 -> Valor del CONTADOR: 1
1Resource id #7 -> Valor del CONTADOR: 1
2Resource id #10 -> Valor del CONTADOR: 1
3Resource id #13 -> Valor del CONTADOR: 1
4Resource id #16 -> Valor del CONTADOR: 1
5Resource id #19 -> Valor del CONTADOR: 1
6Resource id #22 -> Valor del CONTADOR: 1
7Resource id #25 -> Valor del CONTADOR: 1
8Resource id #28 -> Valor del CONTADOR: 1
9Resource id #31 -> Valor del CONTADOR: 1
FIN<BR>
 [2007-04-24 09:53 UTC] tony2001 at phpclub dot net
The behaviour of PECL/oci8 is correct.
The connection resource is closed/destroyed as soon as it goes out of scope.
 [2007-04-24 10:34 UTC] fernandopapa at gmail dot com
Ok, you said than the connection resource is closed when you out of scope, and this is normal behavior from PECL/oci8.
But before PECL, this wasn't the normal behavior?
could be possible than 4.4.3 with default oci8, the behavior was different? do you have some information about that?
Thanks!
 [2007-04-24 10:43 UTC] tony2001 at phpclub dot net
>could be possible than 4.4.3 with default oci8, 
>the behavior was different?

Yes, it is posible.
That's exactly why it is recommended to use PECl/oci8 with PHP4.
PHP4's native oci8 is not supported anymore.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC