<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Tue, 21 May 2013 11:30:24 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Brian Swan's Blog: Using the Zend Framework and the PDO_SQLSRV Driver]]></title>
      <guid>http://www.phpdeveloper.org/news/15786</guid>
      <link>http://www.phpdeveloper.org/news/15786</link>
      <description><![CDATA[<p>
<i>Brian Swan</i> has a new tutorial posted to his MSDN blog today looking at how to use the <a href="http://blogs.msdn.com/b/brian_swan/archive/2011/01/20/using-the-zend-framework-and-the-pdo-sqlsrv-driver.aspx">Zend Framework with the PDO_SQLSRV driver</a> to connect your applications to a SQL Server database.
</p>
<blockquote>
A couple of months ago, <a href="http://twitter.com/#!/akrabat">Rob Allen</a> pointed out <a href="http://akrabat.com/php/sqlsrv-v2-and-long-field-names/">in a blog post</a> that no Zend Framework PDO adapter existed for SQL Server. But, he also noted that it would be easy to write one...so he did: <a href="https://github.com/akrabat/Akrabat/blob/master/zf1/Akrabat/Db/Adapter/Pdo/Sqlsrv.php">https://github.com/akrabat/Akrabat/blob/master/zf1/Akrabat/Db/Adapter/Pdo/Sqlsrv.php</a>. Rob also mentioned that it would be very easy to use his adapter with the Zend Framework, but I wondered just how easy - that's what I'll investigate in this post. (Cut to the chase: it is very easy.)
</blockquote>
<p>
<i>Brian</i> takes the long way around for those that want the details. He talks about setting up Zend_Tool for Windows, setting up the <a href="http://akrabat.com/zend-framework-tutorial/">Zend Framework tutorial</a> and creating the application. This includes setting up the Apache rewrite rules (mod_rewrite), adding in the database information to your application.ini file and creating a basic table on the SQL Server database to connect to (based on SQL included with the tutorial).
</p>]]></description>
      <pubDate>Fri, 21 Jan 2011 12:52:20 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Brian Swan's Blog: How to Change Database Settings with the PDO_SQLSRV Driver]]></title>
      <guid>http://www.phpdeveloper.org/news/15562</guid>
      <link>http://www.phpdeveloper.org/news/15562</link>
      <description><![CDATA[<p>
<i>Brian Swan</i> has <a href="http://blogs.msdn.com/b/brian_swan/archive/2010/12/09/how-to-change-database-settings-with-the-pdo-sqlsrv-driver.aspx">a new post to his blog</a> 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.
</p>
<blockquote>
The short story is this: If you are using the <a href="http://msdn.microsoft.com/en-us/library/ff628175(SQL.90).aspx">PDO_SQLSRV</a> driver and you want to execute a query that changes a database setting (e.g. <a href="http://msdn.microsoft.com/en-us/library/ms189837.aspx">SET NOCOUNT ON</a>), use the <a href="http://msdn.microsoft.com/en-us/library/ff628189(SQL.90).aspx">PDO::query</a> method with the <a href="http://msdn.microsoft.com/en-us/library/ff754356(SQL.90).aspx">PDO::SQLSRV_ATTR_DIRECT_QUERY</a> 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.
</blockquote>
<p>
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 <a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-33-78-metablogapi/6175.image_5F00_750749DD.png">this</a> to <a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-33-78-metablogapi/0317.image_5F00_218053F7.png">this</a>.
</p>]]></description>
      <pubDate>Fri, 10 Dec 2010 09:38:27 -0600</pubDate>
    </item>
  </channel>
</rss>
