We connect to our MSSQL server with the standard mssql_* functions. We're considering switching to ODBC for various reasons.

I started testing that scenario today and have run into a problem. Here's an example of how that problem crops up

PHP Code:
$db HeritageDB::getConnection();

// This query will return 10 rows
$result $db->query'EXEC SomeStoreProcedure' );

// Fetch just the first row
$row $result->fetchRow();

// Commented out on purpose - read below
// $result->free();

$result2 $db->query'EXEC SomeOtherStoredProc' ); 
What's happening is that when the 2nd query is called without freeing the first result, the following error comes back from SQL

Warning: odbc_exec() [function.odbc-exec]: SQL error: [FreeTDS][SQL Server]Invalid cursor state, SQL state 24000 in SQLExecDirect
Now, if the first query returned only 1 row (or, we fetched all 10 first), then the 2nd query would not trigger this warning. Also, uncommenting the calls to free() gets rid of the error too. So basically, anytime a cursor on a result-set is left in a remedial state - where it hasn't been freed or is pointing to a row that isn't the first/last row of the set.

Looking around led me to find this Microsoft knowledge base article - we're investigating the options under the WORKAROUND section (#1 is not an option, #2 is unlikely)

I should note that these warnings don't crop up when using the mssql_* family of functions.