-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reuse prepared statements in the SQL Server driver #2493
Comments
@morozov unless a new |
@Ocramius you're saying there's no need to keep the As for the test, what kind of test would you like to see? I assume most of the functional tests cover/use |
Unfortunately, this change breaks the test suite on my test system for the
Client System:
Server:
@morozov could you tell which version of the SQLSRV Driver you're using, and on what platform? |
I'm using Windows 2012 Server, SQL Server 2012, PHP 5.6.25 NTS, sqlsrv 3.2 (client and server on the same machine). Just re-ran the failing test, it still passes. It looks like the table DDL is executed for each data set and fails for all data sets except # 0 (the exception is caught but suppressed). I'd try either creating the table once for the whole suite, or drop it explicitly after each test. I'm just speculating, but the DDL query execution (even failing) may invalidate some internal object cache which prevents the 2nd statement from being prepared. |
@morozov thank you. I see you're using PHP5. Would you mind to test it with PHP7 on Windows |
|
@xalopp I've just checked it with PHP 7.0.10 and sqlsrv 4.1.1 on the same server, and the test still passes. |
@morozov thanks for your help. Looks this is a Linux specific bug in the sqlsrv driver :-( |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Internally
SQLSrvStatement::execute()
callssqlsrv_query()
which means that even if the same instance ofSQLSrvStatement
is executed multiple times, it creates a new one-off statement.Performance-wise, the combination of
sqlsrv_prepare()
+sqlsrv_execute()
is preferred tosqlsrv_query()
:However, in case if the statement is not going to be reused,
sqlsrv_query()
is preferrable:It would be nice to have a way to specify whether the statement is going to be reused so that the most optimal API could be used.
The text was updated successfully, but these errors were encountered: