News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Brian Swan's Blog:
How to Change Database Settings with the PDO_SQLSRV Driver
December 10, 2010 @ 09:38:27

Brian Swan has a new post to his blog about how you can change the database settings in your SQL Server database (with a connection using the PDO_SQLSRV driver) through a SQL query.

The short story is this: If you are using the PDO_SQLSRV driver and you want to execute a query that changes a database setting (e.g. SET NOCOUNT ON), use the PDO::query method with the PDO::SQLSRV_ATTR_DIRECT_QUERY attribute. If you use PDO::query without that attribute, the database setting you expected to change may not be applied to subsequent queries. The longer story has to do with why this is the case, which is what I'll explain in this post.

The problem is that, when changes to settings are made, they don't seem to stick. Future queries act like they were never even updated. The solution to the problem is to use that PDO::SQLSRV_ATTR_DIRECT_QUERY attribute on the connection (set to true). You can see the difference in execution from this to this.

0 comments voice your opinion now!
pdo sqlserver database setting pdosqlsrv driver


blog comments powered by Disqus

Similar Posts

Developer.com: Developing a Ajax-driven Shopping Cart with PHP and Prototype

SitePoint PHP Blog: Configuring Your Store’s Settings with the eBay Trading API

Eran Galperin's Blog: Database Optimization Techniques You Can Actually Use

Alexander Netkachev's Blog: About Eclipse PHP IDE php.ini location

Brian Swan's Blog: PHP Driver for SQL Server - Request for Feature Feedback


Community Events

Don't see your event here?
Let us know!


conference introduction community opinion configure interview library performance example api series podcast laravel symfony2 release framework application php7 install voicesoftheelephpant

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework