php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5980 Informix ifx_connect reuses closed connection resource id
Submitted: 2000-08-05 01:47 UTC Modified: 2000-08-07 16:48 UTC
From: mlemos at acm dot org Assigned: danny (profile)
Status: Closed Package: Misbehaving function
PHP Version: 4.0 Latest CVS (05/08/2000) OS: Linux RH 6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mlemos at acm dot org
New email:
PHP Version: OS:

 

 [2000-08-05 01:47 UTC] mlemos at acm dot org
It seems that when ifx_connect is called twice in the same script using the
same connection parameters it returns the same connection resource id even
when the connection was closed before calling ifx_connect for the second
time.

Try the following example to see the problem.

Function Doit($go)
{
 global $informix_server,$database_name,$database,$user,$password,$some_table;
 
 PutEnv("INFORMIXSERVER=$informix_server");
 if(($connection=ifx_connect($database,$user,$password)))
 {
  if(($result=ifx_query("SELECT * FROM $some_table",$connection)))
   ifx_free_result($result);
  else
   echo "Go $go Query error: ".ifx_errormsg(),"\n";
  ifx_Close($connection);
 }
 else
  echo "Connection error: ".ifx_errormsg(),"\n";
}

 $informix_server="demo_on";
 $database_name="my_database";
 $user="informix";
 $password="informixpassword";
 $some_table="my_table";
 $database="$database_name@$informix_server";
 DoIt(1);
 DoIt(2);

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-05 16:10 UTC] danny@php.net
It looks like it could be a Zend problem.

The code is essentially unchanged since PHP3 where it works.

The resource is deleted on ifx_close but somehow Zend
manages to find it again on connect() so the driver thinks it still is active
and reuses it. Connect() will *always* check if a connection
does not already exist in an attempt to save connections.

The (p)connect()/close() code is the same as in mysql, does the same happen
with mysql ?

Danny
---
 [2000-08-07 16:48 UTC] danny@php.net
ifx_close() no longer *really* closes until the script ends or until you open
a *different* database connection. This can recycle non-persistent
connections within the script saving reconnection overhead. 
As far as I can see, it is what Mysql does.
Nothing changed for persistent connections.

Danny
---
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 06:01:32 2025 UTC