Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP ODBC connection to iSeries persists after PHP script ends

Status
Not open for further replies.

kv194

Programmer
Sep 14, 2005
4
US
Hello,

We are running PHP 5.3.3 on WinXP Service Pack 3. We use ODBC (IBM iSeries Access ODBC driver) via PHP to connect to an IBM System i (model i5-570).

The problem is that when the execution of PHP code is interrupted for any reason (i.e. power failure, network error, or the user closing the PHP window), the ODBC connection continues to run on the iSeries.

We use ODBC_CONNECT to make the connection between PHP and the System i, so the connection should not persist, but it does. This is a problem because when the user starts again, another connection is made even as the previous one continues to process on the System i. This eats up resources in a hurry.

We don't have this issue with any other software that connects to the System i, so the belief is that the issue lies on the PHP side.

Does anyone know of a way to resolve this? It's really delaying a project because a failure to get around this issue means that we'll have to find an alternative to PHP and weeks of PHP development time would then be wasted.

Thanks,
KV194
 
sounds like you're missing an odbc_close()

You should have something like this at the end of your php code.

Code:
odbc_close($connection);
 
@frumpus: Thanks for responding. There is an odbc_close() at the end of the script. The problem is that the user can close the window before the PHP script returns a value. While that's not supposed to happen, the fact is that it can (and did) really happen. When this (or some other connection-killing interruption) occurs, the System i just keeps chugging along as though the ODBC connection to the PHP script is still viable. We made sure to avoid odbc_pconnect to avoid persistence, but it certainly seems that something is forcing a persistent connection. We just have no idea what it could be.

Thanks,
kv194
 
Resolution (of sorts):

We've found through additional testing that the issue is on the System i side[surprise], not PHP[thumbsup]. The issue was successfully replicated using a System i tool called "iSeries Navigator". When running an SQL via the tool's query function, we closed the active window and then checked the System i. Sure enough, there was the corresponding ODBC job still chugging away. We never knew this could happen.

Bottom line: this is a System i issue, folks. Please consider this PHP thread closed.

Finally, and most importantly, please accept our thanks for your interest and your input.

-KV194
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top