<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Rob Allen&#039;s DevNotes &#187; WinPHP Challenge</title>
	<atom:link href="http://akrabat.com/category/winphp-challenge/feed/" rel="self" type="application/rss+xml" />
	<link>http://akrabat.com</link>
	<description>Developing PHP software in the Real World, by Rob Allen</description>
	<lastBuildDate>Wed, 01 Sep 2010 14:33:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>WinPHP wrap-up thoughts</title>
		<link>http://akrabat.com/winphp-challenge/winphp-wrap-up-thoughts/</link>
		<comments>http://akrabat.com/winphp-challenge/winphp-wrap-up-thoughts/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 20:56:52 +0000</pubDate>
		<dc:creator>Rob...</dc:creator>
				<category><![CDATA[WinPHP Challenge]]></category>

		<guid isPermaLink="false">http://akrabat.com/?p=664</guid>
		<description><![CDATA[This post is part of a series about my experiences building a PHP app for Windows Server 2008 and IIS 7 for the European WinPHP Challenge 2009 which is sponsored by iBuildings, Microsoft and Leaseweb. The WinPHP challenge come come to an end and I'm fairly happy with how SuccesSQL has come. I wish I [...]]]></description>
			<content:encoded><![CDATA[<p><em style="font-size: 0.9em">This post is part of a series about my experiences building a PHP app for Windows Server 2008 and IIS 7 for the <a href="http://wiki.phpconference.nl/2009_WinPHP_Challenge">European WinPHP Challenge 2009</a> which is  sponsored by iBuildings, Microsoft and Leaseweb.</em></p>
<p>The WinPHP challenge come come to an end and I'm fairly happy with how <a href="http://test.successql.org">SuccesSQL</a> has come. I wish I had realised exactly how little time I had in May though. Somehow I managed to forget that we had three family birthdays, a Christening and a weekend holiday to fit in during the month...</p>
<p>I already knew that PHP worked great on Windows and SuccesSQL again proves that PHP is truly cross-platform. The areas that I wanted to explore and learn a little about were running PHP on IIS and using the SqlSrv database connector.</p>
<p>I learnt a <em>lot</em> about setting up PHP in Windows. It's amazing how much easier it was the second time when I installed it on the Leaseweb server. The <a href="http://www.microsoft.com/web/">Web Platform Installer</a> is very good as long as you remember to stop the IIS service before running it! It's also very odd that the installer doesn't install PEAR or PDO_ODBC. I'm very glad that it uses the exact same installer as available at <a href="http://windows.php.net">windows.php.net</a>, as it makes correcting these oversights trivial.</p>
<p>Fortunately, <a href="http://dev.juokaz.com/">Juozas Kaziukenas</a> also wanted to connect to SQL Server, so we collaborated on a Zend Framework Database adapter for SqlSrv on codepex at <a href="http://zfmssql.codeplex.com/">http://zfmssql.codeplex.com/</a>. Please download and exercise that too as all bug reports (and patches) will be gratefully received!</p>
<p>Like Juokaz, I also really enjoyed the community aspect of this competition too. Twitter was alive with <a href="http://search.twitter.com/search?q=%23winphp">#winphp</a> tweets and it felt as co-operative rather than competitive as we helped each other overcome obstacles.</p>
]]></content:encoded>
			<wfw:commentRss>http://akrabat.com/winphp-challenge/winphp-wrap-up-thoughts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SuccesSQL demo online</title>
		<link>http://akrabat.com/winphp-challenge/successql-demo-online/</link>
		<comments>http://akrabat.com/winphp-challenge/successql-demo-online/#comments</comments>
		<pubDate>Sun, 31 May 2009 20:08:36 +0000</pubDate>
		<dc:creator>Rob...</dc:creator>
				<category><![CDATA[WinPHP Challenge]]></category>

		<guid isPermaLink="false">http://akrabat.com/?p=662</guid>
		<description><![CDATA[This post is part of a series about my experiences building a PHP app for Windows Server 2008 and IIS 7 for the European WinPHP Challenge 2009 which is sponsored by iBuildings, Microsoft and Leaseweb. The WinPHP challenge comes to an end around now, so I've put up a demo installation of SuccesSQL (v0.01!) at [...]]]></description>
			<content:encoded><![CDATA[<p><em style="font-size: 0.9em">This post is part of a series about my experiences building a PHP app for Windows Server 2008 and IIS 7 for the <a href="http://wiki.phpconference.nl/2009_WinPHP_Challenge">European WinPHP Challenge 2009</a> which is  sponsored by iBuildings, Microsoft and Leaseweb.</em></p>
<p>The WinPHP challenge comes to an end around now, so I've put up a demo installation of SuccesSQL (v0.01!) at <a href="http://test.successql.org">http://test.successql.org</a>. The test site takes a lot longer to display the first page than version running in my VM and I have no idea why!</p>
<p>The source code is released under the New BSD license and is available from <a href="http://svn.akrabat.com/svn/successql">my subversion repository</a>.</p>
<p>I expect that this code isn't as secure as it should be and isn't especially well tested either. As such, I highly recommend that you don't use it on important databases or on a public facing web server!</p>
<p>Obligatory screen shot:</p>
<p><img src="http://akrabat.com/wp-content/uploads/2009-testsuccessfulorg01.jpg" alt="test.successful.org.01.jpg" border="0" width="500" height="451" /></p>
<p>I've still got lots to do though, but there's enough done that I'm using it for work related stuff when I need to look something up, but can't be bothered to wait for the SQL Server Management tool to get around to starting up. In that sense, it's already a success!</p>
]]></content:encoded>
			<wfw:commentRss>http://akrabat.com/winphp-challenge/successql-demo-online/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Metadata from Zend_Db_Table_Abstract</title>
		<link>http://akrabat.com/zend-framework/metadata-from-zend_db_table_abstract/</link>
		<comments>http://akrabat.com/zend-framework/metadata-from-zend_db_table_abstract/#comments</comments>
		<pubDate>Thu, 28 May 2009 06:06:40 +0000</pubDate>
		<dc:creator>Rob...</dc:creator>
				<category><![CDATA[WinPHP Challenge]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://akrabat.com/?p=658</guid>
		<description><![CDATA[This post is part of a series about my experiences building a PHP app for Windows Server 2008 and IIS 7 for the European WinPHP Challenge 2009 which is sponsored by iBuildings, Microsoft and Leaseweb. I finally found some more time to work on SuccesSQL and can now display table structure information: Zend_Db_Table provides all [...]]]></description>
			<content:encoded><![CDATA[<p><em style="font-size: 0.9em">This post is part of a series about my experiences building a PHP app for Windows Server 2008 and IIS 7 for the <a href="http://wiki.phpconference.nl/2009_WinPHP_Challenge">European WinPHP Challenge 2009</a> which is  sponsored by iBuildings, Microsoft and Leaseweb.</em></p>
<p>I finally found some more time to work on SuccesSQL and can now display table structure information:</p>
<p><img src="http://akrabat.com/wp-content/uploads/2009-successql-structure-1.jpg" alt="successql_structure-1.jpg" border="0" width="500" height="305" /></p>
<p><tt>Zend_Db_Table</tt> provides all this information directly which is quite useful, however the intended use-case for <tt>Zend_Db_Table</tt> is that you extend <tt>Zend_Db_Table_Abstract</tt> for each table that you want to interact with. Obviously, SuccesSQL doesn't know in advance the names of the tables, so I created a stub class that allowed me to instantiate a <tt>Zend_Db_Table</tt> dynamically:</p>
<pre class="phpcode"><span style="color: #0000BB">
</span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">SSQL_Db_Table&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">Zend_Db_Table_Abstract
</span><span style="color: #007700">{
}
</span>
</span></code></pre>
<p>Then, for any given table, I can instantiate like this:</p>
<pre class="phpcode"><span style="color: #0000BB">
$table&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SSQL_Db_Table</span><span style="color: #007700">(array(</span><span style="color: #DD0000">'name'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">$tableName</span><span style="color: #007700">));
</span>
</span></code></pre>
<p>The metadata about the table is stored in a protected member variable called <tt>_metadata</tt>. As this is protected, it's not accessible, outside of the class, so I created an accessor method to allow me to get at the data:</p>
<pre class="phpcode"><span style="color: #0000BB">
</span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">SSQL_Db_Table&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">Zend_Db_Table_Abstract
</span><span style="color: #007700">{

&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000BB">getMetadata</span><span style="color: #007700">()
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(empty(</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">_metadata</span><span style="color: #007700">))&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">_setupMetadata</span><span style="color: #007700">();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">_metadata</span><span style="color: #007700">;
&nbsp;&nbsp;&nbsp;&nbsp;}

}
</span>
</span></code></pre>
<p>Interestingly, <tt>Zend_Db_Table_Abstract</tt> lazily loads the <tt>_metadata</tt> variable and so I had to check if it had been loaded and if not, set it up.  The data returned is an multi-dimensional array, with one sub-array per field. A dump looks like this:</p>
<pre class="phpcode"><span style="color: #0000BB">
</span><span style="color: #007700">array
&nbsp;&nbsp;</span><span style="color: #DD0000">'id'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;array
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'SCHEMA_NAME'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">null
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'TABLE_NAME'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">string&nbsp;</span><span style="color: #DD0000">'albums'&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">length</span><span style="color: #007700">=</span><span style="color: #0000BB">6</span><span style="color: #007700">)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'COLUMN_NAME'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">string&nbsp;</span><span style="color: #DD0000">'id'&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">length</span><span style="color: #007700">=</span><span style="color: #0000BB">2</span><span style="color: #007700">)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'COLUMN_POSITION'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">int&nbsp;1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'DATA_TYPE'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">string&nbsp;</span><span style="color: #DD0000">'int'&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">length</span><span style="color: #007700">=</span><span style="color: #0000BB">3</span><span style="color: #007700">)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'DEFAULT'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">null
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'NULLABLE'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">boolean&nbsp;false
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'LENGTH'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">int&nbsp;4
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'SCALE'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">int&nbsp;0
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'PRECISION'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">int&nbsp;10
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'UNSIGNED'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">null
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'PRIMARY'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">boolean&nbsp;true
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'PRIMARY_POSITION'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">int&nbsp;1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'IDENTITY'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">boolean&nbsp;true
&nbsp;&nbsp;</span><span style="color: #DD0000">'artist'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;array
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'SCHEMA_NAME'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">null
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">[</span><span style="color: #0000BB">etc</span><span style="color: #007700">]
</span>
</span></code></pre>
<p>From then on, it's just a case of display formatting.</p>
]]></content:encoded>
			<wfw:commentRss>http://akrabat.com/zend-framework/metadata-from-zend_db_table_abstract/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Retrieving a list of databases from SQL Server</title>
		<link>http://akrabat.com/winphp-challenge/retriving-a-list-of-database-from-sql-server/</link>
		<comments>http://akrabat.com/winphp-challenge/retriving-a-list-of-database-from-sql-server/#comments</comments>
		<pubDate>Tue, 19 May 2009 19:50:13 +0000</pubDate>
		<dc:creator>Rob...</dc:creator>
				<category><![CDATA[WinPHP Challenge]]></category>

		<guid isPermaLink="false">http://akrabat.com/?p=646</guid>
		<description><![CDATA[This post is part of a series about my experiences building a PHP app for Windows Server 2008 and IIS 7 for the European WinPHP Challenge 2009 which is sponsored by iBuildings, Microsoft and Leaseweb. I need to get a list of databases from SQL Server for the currently logged in user. Initially, I found [...]]]></description>
			<content:encoded><![CDATA[<p><em style="font-size: 0.9em">This post is part of a series about my experiences building a PHP app for Windows Server 2008 and IIS 7 for the <a href="http://wiki.phpconference.nl/2009_WinPHP_Challenge">European WinPHP Challenge 2009</a> which is  sponsored by iBuildings, Microsoft and Leaseweb.</em></p>
<p>I need to get a list of databases from SQL Server for the currently logged in user. Initially, I found a built in function <tt>sp_databases</tt>. This looked promising, until I discovered that it didn't work for my user. I'm pretty sure that it's related to permissions. The user just has db_owner on a specific database and nothing else. (Mainly as I don't know how to set anything else!)</p>
<p>A bit of googling provided enabled me to develop this SQL statement:</p>
<pre class="phpcode"><span style="color: #0000BB">
SELECT&nbsp;name</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">collation_name
FROM&nbsp;sys</span><span style="color: #007700">.</span><span style="color: #0000BB">databases
WHERE&nbsp;name&nbsp;NOT&nbsp;IN&nbsp;</span><span style="color: #007700">(</span><span style="color: #DD0000">'master'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'tempdb'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'model'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'msdb'</span><span style="color: #007700">);
</span>
</span></code></pre>
<p>This works, but gives me a list of all (non-system) databases, but doesn't tell me which ones I have permission to actually access.</p>
<p>I'm sure there's a better way, but I discovered that if I try to <tt>use</tt> a database, then I get an error message back, so a simple <tt>foreach</tt> loop solved my problem:</p>
<pre class="phpcode"><span style="color: #0000BB">
$validDatabases&nbsp;</span><span style="color: #007700">=&nbsp;array();
foreach(</span><span style="color: #0000BB">$databases&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$name</span><span style="color: #007700">)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$sql&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"USE&nbsp;[</span><span style="color: #0000BB">$name</span><span style="color: #DD0000">]"</span><span style="color: #007700">;
&nbsp;&nbsp;&nbsp;&nbsp;try&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">_db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #0000BB">$sql</span><span style="color: #007700">);
&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;catch&nbsp;(</span><span style="color: #0000BB">Exception&nbsp;$e</span><span style="color: #007700">)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;failed&nbsp;to&nbsp;access&nbsp;the&nbsp;database&nbsp;-&nbsp;ignore&nbsp;it
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">continue;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$validDatabases</span><span style="color: #007700">[]&nbsp;=&nbsp;</span><span style="color: #0000BB">$name</span><span style="color: #007700">;
}
</span>
</span></code></pre>
<p>Now... this is <em>inelegant</em>. Surely there's a better way?! </p>
<p>On the plus side, it works ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://akrabat.com/winphp-challenge/retriving-a-list-of-database-from-sql-server/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>SQL Server troubles</title>
		<link>http://akrabat.com/winphp-challenge/sql-server-troubles/</link>
		<comments>http://akrabat.com/winphp-challenge/sql-server-troubles/#comments</comments>
		<pubDate>Sat, 16 May 2009 21:01:26 +0000</pubDate>
		<dc:creator>Rob...</dc:creator>
				<category><![CDATA[WinPHP Challenge]]></category>

		<guid isPermaLink="false">http://akrabat.com/?p=643</guid>
		<description><![CDATA[This post is part of a series about my experiences building a PHP app for Windows Server 2008 and IIS 7 for the European WinPHP Challenge 2009 which is sponsored by iBuildings, Microsoft and Leaseweb. I'm now at the stage where I'm writing code and came across an error: Message: 2 [Microsoft][SQL Native Client] Named [...]]]></description>
			<content:encoded><![CDATA[<p><em style="font-size: 0.9em">This post is part of a series about my experiences building a PHP app for Windows Server 2008 and IIS 7 for the <a href="http://wiki.phpconference.nl/2009_WinPHP_Challenge">European WinPHP Challenge 2009</a> which is  sponsored by iBuildings, Microsoft and Leaseweb.</em></p>
<p>I'm now at the stage where I'm writing code and came across an error:</p>
<pre>
Message: 2 [Microsoft][SQL Native Client]
    Named Pipes Provider: Could not open a connection to SQL Server [2]. </pre>
<p>That seemed a little odd, so I fired up the Microsoft SQL Server Management Studio and logged in with the credentials that I'm using in the web app. It let me log in, so I went to click on the Databases item in the Object Explorer and got this message:</p>
<p><img src="http://akrabat.com/wp-content/uploads/2009-sqlmgnt-error.jpg" alt="sqlmgnt_error.jpg" border="0" width="612" height="165" /></p>
<p>Any ideas? All I've found when googling is suggestions to reinstall...</p>
]]></content:encoded>
			<wfw:commentRss>http://akrabat.com/winphp-challenge/sql-server-troubles/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Zend Framework URL Rewriting in IIS7</title>
		<link>http://akrabat.com/winphp-challenge/zend-framework-url-rewriting-in-iis7/</link>
		<comments>http://akrabat.com/winphp-challenge/zend-framework-url-rewriting-in-iis7/#comments</comments>
		<pubDate>Mon, 11 May 2009 05:53:03 +0000</pubDate>
		<dc:creator>Rob...</dc:creator>
				<category><![CDATA[WinPHP Challenge]]></category>

		<guid isPermaLink="false">http://akrabat.com/?p=638</guid>
		<description><![CDATA[This post is part of a series about my experiences building a PHP app for Windows Server 2008 and IIS 7 for the European WinPHP Challenge 2009 which is sponsored by iBuildings, Microsoft and Leaseweb. To get my Zend Framework Tutorial working with my IIS7 &#038; MS SQL server set up, I needed two things: [...]]]></description>
			<content:encoded><![CDATA[<p><em style="font-size: 0.9em">This post is part of a series about my experiences building a PHP app for Windows Server 2008 and IIS 7 for the <a href="http://wiki.phpconference.nl/2009_WinPHP_Challenge">European WinPHP Challenge 2009</a> which is  sponsored by iBuildings, Microsoft and Leaseweb.</em></p>
<p>To get my <a href="/zend-framework-tutorial">Zend Framework Tutorial</a> working with my IIS7 &#038; MS SQL server set up, I needed two things:</p>
<ol>
<li>A <a href="http://zfmssql.codeplex.com/">Sqlsrv adapter for Zend Framework</a>. </li>
<li>A replacement Apache's <a href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html">mod_rewrite</a> module.</li>
</ol>
<p>I've already covered the Sqlsrv adapter, so let's look at rewriting requests with IIS7's <a href="http://www.iis.net/extensions/URLRewrite">URL Rewrite</a> module. As with everything in IIS, you get at this tool via the IIS Manager GUI. Be aware though that the <em>Url Rewrite</em> icon is available at server level and at the website level. </p>
<p>You need the website level which is accessed under the "Sites" section which is under the "Server name" section. In my case it is called "Default Web Site". You now click on "Import Rules" on the <em>right</em> hand action list and get this screen:<br />
<img src="http://akrabat.com/wp-content/uploads/2009-iismanager-import-rewrite-rules.jpg" alt="IISManager-import-rewrite-rules.jpg" border="0" width="500" height="308" /></p>
<p>Simply paste in these rules:</p>
<pre>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ /zf-tutorial/public/index.php [NC,L]
</pre>
<p>and press "Apply"</p>
<p>Note that this rules doesn't match the official ZF rules, but it performs essentially the same functionality and generates a much clearer rule within the IIS URL Rewrite manager. </p>
<p>Also, you need to put the full path to the index.php file for it to work. It's much easier to create a new website within the IIS manager and point it at the public directory.</p>
<p>My Zend Framework tutorial website is now working though, so it's full steam ahead on the actual application.</p>
]]></content:encoded>
			<wfw:commentRss>http://akrabat.com/winphp-challenge/zend-framework-url-rewriting-in-iis7/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Zend Framework connection to SQL Server using SqlSrv</title>
		<link>http://akrabat.com/winphp-challenge/zend-framework-connection-to-sql-server-using-sqlsrv/</link>
		<comments>http://akrabat.com/winphp-challenge/zend-framework-connection-to-sql-server-using-sqlsrv/#comments</comments>
		<pubDate>Sun, 10 May 2009 16:30:55 +0000</pubDate>
		<dc:creator>Rob...</dc:creator>
				<category><![CDATA[WinPHP Challenge]]></category>

		<guid isPermaLink="false">http://akrabat.com/?p=636</guid>
		<description><![CDATA[This post is part of a series about my experiences building a PHP app for Windows Server 2008 and IIS 7 for the European WinPHP Challenge 2009 which is sponsored by iBuildings, Microsoft and Leaseweb. I haven't managed to get much time on the challenge this week as I had hoped. Both my sons' birthday [...]]]></description>
			<content:encoded><![CDATA[<p><em style="font-size: 0.9em">This post is part of a series about my experiences building a PHP app for Windows Server 2008 and IIS 7 for the <a href="http://wiki.phpconference.nl/2009_WinPHP_Challenge">European WinPHP Challenge 2009</a> which is  sponsored by iBuildings, Microsoft and Leaseweb.</em></p>
<p>I haven't managed to get much time on the challenge this week as I had hoped. Both my sons' birthday parties have taken place along with one son's birthday (the other's is tomorrow).</p>
<p>It turns out that fellow challenger <a href="http://dev.juokaz.com/">Juozas Kaziukenas</a> also needs a connection between Zend Framework and SQL Server, so we have joined forces to create <tt>App_Db_Adapter_SqlSrv</tt> and associated classes. Juozas started a project on codeplex at <a href="http://zfmssql.codeplex.com/">http://zfmssql.codeplex.com/</a> and has enabled me to commit to the project too.</p>
<p>Juozas committed an initial implementation and so far I've updated the <tt>_connect()</tt> method to allow for all the parameters supported by <tt>sqlserv_connect()</tt>.</p>
<p>My current application.ini looks like this:</p>
<pre>
resources.db.adapter = SQLSRV
resources.db.params.adapterNamespace = "App_Db_Adapter"
resources.db.params.host = "RKAWIN2008\SQLEXPRESS"
resources.db.params.username = "rob"
resources.db.params.password = "123456"
resources.db.params.dbname = zf-tutorial
resources.db.params.driver_options.ConnectionPooling = 1
resources.db.params.driver_options.Encrypt = 0
resources.db.params.driver_options.TransactionIsolation = SQLSRV_TXN_READ_COMMITTED
</pre>
<p>The adapter correctly converts the <tt>SQLSRV_TXN_READ_COMMITTED</tt> string from the ini file into the constant value required by the <tt>sqlsrv_connect()</tt> function using the very useful <a href="http://php.net/constant"><tt>constant()</tt></a> function.</p>
<p>I had a slight hiccup with detection of the table's primary key. Microsoft's <a href="http://msdn.microsoft.com/en-us/library/ms189813.aspx">documentation</a> is quit clear once you have found what you are looking for, so that was easily fixed.</p>
<p>At this point the adapter is working for my ZF tutorial, though more work needs to be done on it.</p>
]]></content:encoded>
			<wfw:commentRss>http://akrabat.com/winphp-challenge/zend-framework-connection-to-sql-server-using-sqlsrv/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>MSSQL and PHP</title>
		<link>http://akrabat.com/winphp-challenge/mssql-and-php/</link>
		<comments>http://akrabat.com/winphp-challenge/mssql-and-php/#comments</comments>
		<pubDate>Mon, 04 May 2009 10:12:05 +0000</pubDate>
		<dc:creator>Rob...</dc:creator>
				<category><![CDATA[WinPHP Challenge]]></category>

		<guid isPermaLink="false">http://akrabat.com/?p=630</guid>
		<description><![CDATA[This post is part of a series about my experiences building a PHP app for Windows Server 2008 and IIS 7 for the European WinPHP Challenge 2009 which is sponsored by iBuildings, Microsoft and Leaseweb. It's time to connect PHP to MS SQL Server. To make life simple, I decided to take my Zend Framework [...]]]></description>
			<content:encoded><![CDATA[<p><em style="font-size: 0.9em">This post is part of a series about my experiences building a PHP app for Windows Server 2008 and IIS 7 for the <a href="http://wiki.phpconference.nl/2009_WinPHP_Challenge">European WinPHP Challenge 2009</a> which is  sponsored by iBuildings, Microsoft and Leaseweb.</em></p>
<p>It's time to connect PHP to MS SQL Server. To make life simple, I decided to take my Zend Framework tutorial and get that going.</p>
<p>I created the database and albums table using the SQL Server Management Studio and populated with a couple of rows.</p>
<p>Using The <a href="http://msdn.microsoft.com/en-us/library/cc296152(SQL.90).aspx">SqlSrv API Reference</a>, I started by with a simple test PHP script:</p>
<pre class="phpcode"><span style="color: #0000BB">
$connectionInfo&nbsp;</span><span style="color: #007700">=&nbsp;array(
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'Database'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'zf-tutorial'</span><span style="color: #007700">,
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'UID'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'rob'</span><span style="color: #007700">,
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'PWD'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'123456'</span><span style="color: #007700">,
);
</span><span style="color: #0000BB">$conn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">sqlsrv_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'RKAWIN2008\SQLEXPRESS'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$connectionInfo</span><span style="color: #007700">);

if&nbsp;(</span><span style="color: #0000BB">$conn&nbsp;</span><span style="color: #007700">===&nbsp;</span><span style="color: #0000BB">false</span><span style="color: #007700">)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&lt;p&amp;gtConnection&nbsp;could&nbsp;not&nbsp;be&nbsp;established.&lt;/p&amp;gt&nbsp;&lt;pre&gt;"</span><span style="color: #007700">;
&nbsp;&nbsp;&nbsp;&nbsp;die(</span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">sqlsrv_errors</span><span style="color: #007700">(),&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">));
}

</span><span style="color: #FF8000">//&nbsp;Tidy&nbsp;up
</span><span style="color: #0000BB">sqlsrv_free_stmt</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">);
</span><span style="color: #0000BB">sqlsrv_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">);
</span>
</span></code></pre>
<p>which gave me the error:</p>
<pre>
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
</pre>
<p>A quick google around suggested that I needed to install the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=61BF87E0-D031-466B-B09A-6597C21A2E2A&#038;displaylang=en">SQL Server Native Client</a>, so I did :)  This worked!</p>
<p>It seems a little odd that the Web Platform Installer let me install PHP and MSSQL Server Express, but didn't do the native client at the same time!</p>
<p>Once you have a connection, it gets easy! The code to retrieve data from the database and iterate over it is:</p>
<pre class="phpcode"><span style="color: #0000BB">
$sql&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"SELECT&nbsp;*&nbsp;FROM&nbsp;albums"</span><span style="color: #007700">;
</span><span style="color: #0000BB">$stmt&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">sqlsrv_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$sql</span><span style="color: #007700">);
if&nbsp;(</span><span style="color: #0000BB">$stmt&nbsp;</span><span style="color: #007700">===&nbsp;</span><span style="color: #0000BB">false</span><span style="color: #007700">)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&lt;p&gt;Error&nbsp;in&nbsp;query&nbsp;preparation/execution.&lt;/p&gt;"</span><span style="color: #007700">;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;die(</span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">sqlsrv_errors</span><span style="color: #007700">(),&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">));
}

</span><span style="color: #FF8000">//&nbsp;Retrieve&nbsp;each&nbsp;row&nbsp;as&nbsp;an&nbsp;associative&nbsp;array&nbsp;and&nbsp;display&nbsp;the&nbsp;results.
</span><span style="color: #007700">while&nbsp;(</span><span style="color: #0000BB">$row&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">sqlsrv_fetch_array</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SQLSRV_FETCH_ASSOC</span><span style="color: #007700">))&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">'artist'</span><span style="color: #007700">]&nbsp;.&nbsp;</span><span style="color: #DD0000">':&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">'album'</span><span style="color: #007700">]&nbsp;.&nbsp;</span><span style="color: #DD0000">"&lt;br/&gt;n"</span><span style="color: #007700">;
}
</span>
</span></code></pre>
<p>which gives the output:</p>
<p><img src="http://akrabat.com/wp-content/uploads/2009-sqlsrv-working.jpg" alt="sqlsrv_working.jpg" border="0" width="528" height="333" /></p>
<p>The next step is to connect and use a <tt>Zend_Db_Adapter</tt>, but there isn't one yet. I've also discovered that you can't use the SQL Server driver for PHP with PDO, so I'll be creating an <tt>App_Db_Adapter_Sqlsrv</tt> which, assuming it works, I'll propose for addition to Zend Framework.</p>
]]></content:encoded>
			<wfw:commentRss>http://akrabat.com/winphp-challenge/mssql-and-php/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Viewing PHP errors over the network when using IIS</title>
		<link>http://akrabat.com/winphp-challenge/viewing-php-errors-over-the-network-when-using-iis/</link>
		<comments>http://akrabat.com/winphp-challenge/viewing-php-errors-over-the-network-when-using-iis/#comments</comments>
		<pubDate>Sun, 03 May 2009 18:33:57 +0000</pubDate>
		<dc:creator>Rob...</dc:creator>
				<category><![CDATA[WinPHP Challenge]]></category>

		<guid isPermaLink="false">http://akrabat.com/?p=627</guid>
		<description><![CDATA[This post is part of a series about my experiences building a PHP app for Windows Server 2008 and IIS 7 for the European WinPHP Challenge 2009 which is sponsored by iBuildings, Microsoft and Leaseweb. I thought I'd spend a little time sorting out how to connect to MSSQL server using PHP on my Windows [...]]]></description>
			<content:encoded><![CDATA[<p><em style="font-size: 0.9em">This post is part of a series about my experiences building a PHP app for Windows Server 2008 and IIS 7 for the <a href="http://wiki.phpconference.nl/2009_WinPHP_Challenge">European WinPHP Challenge 2009</a> which is  sponsored by iBuildings, Microsoft and Leaseweb.</em></p>
<p>I thought I'd spend a little time sorting out how to connect to MSSQL server using PHP on my Windows 2008 box. I now have my system set up in VMWare Fusion and use SMB to map the wwwroot directory to my OS X environment so I can use my familiar IDE. I am also using Safari for OS X to view the webpages having set up a local entry in my /etc/hosts file.</p>
<p>I quickly noticed that if I made an error, then I'd get back a generic IIS error in the browser:<br />
<img src="http://akrabat.com/wp-content/uploads/2009-iis-internal-error.jpg" alt="iis_internal_error.jpg" border="0" width="635" height="349" /></p>
<p>However, if I viewed this site in IE on the VM using http://localhost as the address, then I could see the actual error.</p>
<p>The solution to this is in the ISS Manager program. Select the server in the left hand tree and then choose the<em> Error Pages</em> option in the main pane. Choosing <em>Edit Feature Settings...</em> in the right hand pane gives access to this window:</p>
<p><img src="http://akrabat.com/wp-content/uploads/2009-editerrorpagessettings.jpg" alt="EditErrorPagesSettings.jpg" border="0" width="397" height="367" /></p>
<p>I changed to <em>Details errors</em> and then started seeing the real error in Safari. Obviously, on a live server, you'd probably want to use the default option of<em> Details errors for local requests and custom error pages for remote requests</em>. It would be tidier if I could set the 192.169.0.x IP range as "local" though.</p>
<p>Getting the MSSQL server connection working is the subject of another post now :)</p>
]]></content:encoded>
			<wfw:commentRss>http://akrabat.com/winphp-challenge/viewing-php-errors-over-the-network-when-using-iis/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The EuroWinPHP application</title>
		<link>http://akrabat.com/winphp-challenge/the-eurowinphp-application/</link>
		<comments>http://akrabat.com/winphp-challenge/the-eurowinphp-application/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 06:03:55 +0000</pubDate>
		<dc:creator>Rob...</dc:creator>
				<category><![CDATA[SuccesSQL]]></category>
		<category><![CDATA[WinPHP Challenge]]></category>

		<guid isPermaLink="false">http://akrabat.com/?p=574</guid>
		<description><![CDATA[This post is part of a series about my experiences building a PHP app for Windows Server 2008 and IIS 7 for the European WinPHP Challenge 2009 which is sponsored by iBuildings, Microsoft and Leaseweb. So.. I've decided on a name: SuccesSQL! I can almost hear the groan from here... What can I say? The [...]]]></description>
			<content:encoded><![CDATA[<p><em style="font-size: 0.9em">This post is part of a series about my experiences building a PHP app for Windows Server 2008 and IIS 7 for the <a href="http://wiki.phpconference.nl/2009_WinPHP_Challenge">European WinPHP Challenge 2009</a> which is  sponsored by iBuildings, Microsoft and Leaseweb.</em></p>
<p>So.. I've decided on a name: <strong>SuccesSQL</strong>! I can almost hear the groan from here... What can I say? The name appealed to me :)</p>
<p>The plan is to write a web based management interface for MS SQL Server databases with a focus on inspecting the data and importing/exporting it. Essentially, I want to be able to inspect the schema and query data without having to go to all the hassle of firing up a VM, connecting to a VPN, starting the SQL Server management application, connecting to the SQL Server, drilling down though five levels of tree on the left just to find out if how many chars a given varchar has been assigned.</p>
<p>I'm intending to write SuccesSql so that it operates quickly with the minimum of fuss.</p>
<h3>The plan</h3>
<p>The application will be written using Zend Framework 1.8. The Zend_Db component doesn't have a good adapter for MSSQL, so the first job will be to write one.</p>
<p>The main goals are:</p>
<ul>
<li>Easy to use UI</li>
<li>Inspect database schema</li>
<li>A data search functionality (global would be nice too)</li>
<li>Ability to run arbitrary SQL statements against the database</li>
</ul>
<p>Going forward, additional functionality that would be useful is:</p>
<ul>
<li>Export a database table / query result-set to a CSV file</li>
<li>Eexport a database to a single text file</li>
<li>Table administration: add, update and delete</li>
<li>Inspection and administration of indexes</li>
<li>Management of users</li>
</ul>
<p>The next step is to understand the <a href="http://blogs.msdn.com/sqlphp/default.aspx">SQL Server Driver for PHP</a> and compare it to using ODBC directly.</p>
]]></content:encoded>
			<wfw:commentRss>http://akrabat.com/winphp-challenge/the-eurowinphp-application/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
