odbc_connect to an Access database seems to have a connection limit
In our PHP application, we use some Access datab开发者_运维百科ases for compatibility with our desktop application. We connect using odbc_connect and DRIVER=Microsoft Access Driver (*.mdb);DBQ=$filename;. This works as expected with most customers...
Some customers experience problems, apparently an error message about a connection limit of 25 connections is thrown and no more connection is possible until the Apache is restarted. Sadly, I have not yet gotten an exact error message, but maybe someone knows this problem already and can enlighten me.
In some cases, it obviously worked to run Apache in CGI mode as the connections get closed after the script finished. But some customers even experience problems in CGI mode.
Is there any way to increase the number of connections or to quickly close the connection? The wierd thing is that I tried to force the problem to appear on my PC, but even with hundreds of concurrent connections I did not have a single error, and the connections seem to close after the script finishes as the .ldb file disappears again.
Maximum connections is set on the webserver in the php.ini with the "MAX USER_CONNECTIONS". When running on localhost, this is rarely a problem. I hade this problem only a few days ago actually when using PDO and MySQL. It worked on localhost, but when I transfered it to a webhosting company it did not work. I solved it by setting persistance to TRUE in the database connection (Means that connections are kept in memory instead of making new connections at each call) If you want more info about this: http://www.php.net/manual/en/features.persistent-connections.php
I would therefore recommend trying ODBC pconnect: http://www.php.net/manual/en/function.odbc-pconnect.php
精彩评论