Skip to Content.
Sympa Menu

freetds - Re: [freetds] Multiple Active Statements

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Daniel Fazekas <fdsubs AT axelero.hu>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Multiple Active Statements
  • Date: Wed, 24 Sep 2003 15:33:21 +0200

Dario wrote:
ok, but if I open multiple connections
the problem persist! how can I solve this?
thanks
Dario

I guess that's because you are not actually opening multiple connections.

PHP has this not always convenient feature in that it caches the database connection parameters, and if you try to open the same database using the exact same parameters (host, login and password), instead of opening a new link, it will just return the previously opened connection's handle.

This is useful for programmers who are lazy about passing the connection handle from one part of their code to another, and might help not to go over the max simultaneous connection limit of the database server.

However, checking odbc_connect()'s documentation in the PHP Manual does not note this feature's existence or a way of turning it off.

On the other hand, the most often used mysql_connect() has this:
"If a second call is made to mysql_connect() with the same arguments, no new link will be established, but instead, the link identifier of the already opened link will be returned. The new_link parameter modifies this behavior and makes mysql_connect() always open a new link, even if mysql_connect() was called before with the same parameters."

So that one lets you control this behavior which is turned on by default.

Almost the same is true of mssql_connect():
"In case a second call is made to mssql_connect() with the same arguments, no new link will be established, but instead, the link identifier of the already opened link will be returned."

But, unfortunately, here you have no way of turning this off.

odbc_pconnect() also notes this:
"Future requests for a connection with the same dsn, user, password combination (via odbc_connect() and odbc_pconnect()) can reuse the persistent connection."


So, I'm guessing that either you are using odbc_pconnect() in at least one of the places, or that the PHP documentation people just forgot to note this feature's existence in the odbc_connect() documentation but it is there nevertheless.


You can check this by var_dump()'ing the two supposedly different connection handles, and see if they are actually the same.


And to solve this, you could use a different user name / password pair for the two different connection; or even simpler, add another ODBC alias to the same server, just to fool PHP into thinking that it's a different server.

Now I don't know how that's exactly done in ODBC, it's beyond me why would anyone want to interface with FreeTDS via ODBC in PHP when you have sybase/sybase_ct for Sybase and mssql for MSSQL.

Since I'm using mssql_connect(), I could simply duplicate the same connection in freetds.conf under a new name.

All this has nothing to do with FreeTDS.

--
Daniel





Archive powered by MHonArc 2.6.24.

Top of Page