I am running into what seems to me to be a bug in the Advantage Database PHP Extension (I know, I know...). I've reported it as a bug, but still haven't heard anything back, so I thought I'd run it by you guys.
Working Code:
for ($i = 0; $i < 100; $i++)
{
$connection = ads_connect( 'DataDirectory=\\some\path\;ServerTypes=2;RightsChecking=Off;TrimTrailingSpaces=true;CommType=TCP_IP;', '', '' );
$results = ads_do( $connection , 'SELECT TOP 1 * FROM projects');
ads_close( $connection );
}
This just loops through 100 times, connects to the db, executes a query, and disconnects.
NON-Working Code:
for ($i = 0; $i < 100; $i++)
{
$connection = ads_connect( 'DataDirectory=\\some\path\;ServerTypes=2;RightsChecking=Off;TrimTrailingSpaces=true;CommType=TCP_IP;', '', '' );
$results = ads_do( $connection , 'SELECT TOP 1 * FROM projects');
$results = ads_do( $connection , 'SELECT TOP 1 * FROM projects');
ads_close( $connection );
}
Notice the second query execution? This loop fails on the 51st cycle (the db server limits each application to 50 simultaneous connections) with the error
Error 6303: Maximum Advantage Database Server connections exceeded.
I've tried several other things including this with no success:
for ($i = 0; $i < 100; $i++)
{
$connection = ads_connect( 'DataDirectory=\\some\path\;ServerTypes=2;RightsChecking=Off;TrimTrailingSpaces=true;CommType=TCP_IP;', '', '' );
$results = ads_do( $connection , 'SELECT TOP 1 * FROM projects');
ads_free_result( $results );
$results = ads_do( $connection , 'SELECT TOP 1 * FROM projects');
ads_free_result( $results );
ads_close( $connection );
}
This, however, DOES fix the problem, and BOTH queries still execute successfully and accurately!!
for ($i = 0; $i < 100; $i++)
{
$connection = ads_connect( 'DataDirectory=\\some\path\;ServerTypes=2;RightsChecking=Off;TrimTrailingSpaces=true;CommType=TCP_IP;', '', '' );
$results = ads_do( $connection , 'SELECT TOP 1 * FROM projects');
ads_close( $connection );
$results = ads_do( $connection , 'SELECT TOP 1 * FROM projects');
ads_close( $connection );
}
This all seems very odd to me... any ideas?
EDIT: I am on PHP 5.2.5 and ADS 8.1