php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8726 ODBC Connections closing between function calls
Submitted: 2001-01-15 16:18 UTC Modified: 2001-01-16 04:38 UTC
From: j_schrab at execpc dot com Assigned:
Status: Closed Package: ODBC related
PHP Version: 4.0.4pl1 OS: Windows NT - SP 6
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: j_schrab at execpc dot com
New email:
PHP Version: OS:

 

 [2001-01-15 16:18 UTC] j_schrab at execpc dot com
I found that under PHP 4.0.4pl1 / IIS 4 / CGI, odbc_pconnect problems occur under normal odbc_connect.

Example:

function a() {
	$connect = odbc_connect(DB_DSN,DB_USERNAME,DB_PASSWORD);
	$query = "SELECT a FROM e";
	$result = odbc_exec($connect, $query);
	while(odbc_fetch_row($result)){
		print odbc_result($result, 1);
	} // while

	odbc_close($connect);

	return true;
} // a

function b() {
	$connect = odbc_connect(DB_DSN,DB_USERNAME,DB_PASSWORD);
	$query = "SELECT b FROM e";
	$result = odbc_exec($connect, $query);
	while(odbc_fetch_row($result)){
		if (odbc_result($result, 1) == 'z') {
			a();
		} // if
		print odbc_result($result, 1);
	} // while

	odbc_close($connect);

	return true;
} // b

A call to function "b" will cause a "Warning: 2 is not a valid ODBC result resource" for "odbc_fetch_row" *if* odbc_result($result, 1) == 'z' was true and, as a result, function "a" was called.  This seems like a bug.  Like the "odbc_close" in function "a" is affecting the condition of the value of "$result" in function "b".  Surely PHP allows multple connections to an ODBC data source, right?!

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-01-16 04:38 UTC] kara@php.net
Multiple connections are supported, but when you try to
connect with exactly the same parameters, an existing
connection will be reused, leading to the behaviour you see.

You can simply omit the calls to odbc_close() since
connections get closed on script termination anyway or better:
Consider making your connection id a global variable or pass
it to your functions.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 03:01:29 2024 UTC