views:

245

answers:

1

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

+3  A: 

The knowledge base has this item on the 6303 error and how to increase the number of connections possible from a client, http://devzone.advantagedatabase.com/dz/content.aspx?Key=17&amp;RefNo=981124-0621. R&D is currently looking into this problem and working to have it resolved in the next service release.

LanceSc
This shows what the error means, and how to allow more connections. It does not, however, explain why you get a max connections error when all connections are closed before reconnecting.
KOGI
LanceSc
LanceSc
Awesome, thanks!
KOGI