<?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>SteveLove.org &#187; mysql</title>
	<atom:link href="http://stevelove.org/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://stevelove.org</link>
	<description>Code, Literature and Other Worthless Pursuits</description>
	<lastBuildDate>Mon, 28 Jun 2010 21:53:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Crash course in blog surgery</title>
		<link>http://stevelove.org/2008/04/16/crash-course-in-blog-surgery/</link>
		<comments>http://stevelove.org/2008/04/16/crash-course-in-blog-surgery/#comments</comments>
		<pubDate>Wed, 16 Apr 2008 19:17:11 +0000</pubDate>
		<dc:creator>Steve Love</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[mssql]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://stevelove.org/?p=15</guid>
		<description><![CDATA[For more than a year now, my intention has been to start posting things I&#8217;ve learned or things I&#8217;ve found to be interesting while developing websites. I was seventy-five percent complete with a site redesign that I planned to launch at same time. What can I say? Things happen. Let&#8217;s just get started then. At [...]]]></description>
			<content:encoded><![CDATA[<p>For more than a year now, my intention has been to start posting things I&#8217;ve learned or things I&#8217;ve found to be interesting while developing websites. I was seventy-five percent complete with a site redesign that I planned to launch at same time. What can I say? Things happen.</p>
<p>Let&#8217;s just get started then.</p>
<p>At work right now, one of my tasks is to add a blog (among many other things) to our core website by the end of this month. This would be very simple if I could just install WordPress, which I&#8217;ve been using for about four years now and with which I&#8217;m quite familiar. The problem is all our databases are Microsoft SQL Server 2005, and WordPress requires MySQL. I initially had our database administrator set up a MySQL database anyway, but it came to a halt when the powers that be said we must use MSSQL.<span id="more-15"></span></p>
<p>I searched and searched for a blog platform that supported MSSQL but only found the enterprise version of Movable Type. Unfortunately, their licensing fees were a deal breaker.</p>
<p>From there, the plan was to develop our own temporary blog solution. I wrote up a brilliant design document and gave it to the infrastructure team, and waited. And waited. Yesterday, work finally began on the project &#8230; until we were once again shut down and told we should be able to port an existing blog platform like WordPress to work with MSSQL.</p>
<p>Sigh.</p>
<p>I spent my whole Monday working on an MSSQL port of WordPress. SQL is not my expertise, so I started with what I knew and found any query that contained a <span class="code">LIMIT</span> and converted it to <span class="code">TOP</span> for MSSQL. Microsoft would do well to add <span class="code">LIMIT</span> to its syntax. Compare the following:</p>
<p>MySQL:<br />
[sql]<br />
&quot;SELECT id,title,post FROM table_name WHERE category_name = &#8216;category&#8217; ORDER BY DESC LIMIT 4,10&quot;<br />
[/sql]</p>
<p>MSSQL:<br />
[sql]<br />
&quot;SELECT TOP 10 id,title,post FROM table_name WHERE category_name = &#8216;category&#8217; AND id NOT IN (SELECT TOP 4 id FROM table_name WHERE category_name = &#8216;category&#8217; ORDER BY DESC) ORDER BY DESC&quot;<br />
[/sql]</p>
<p>After changing those, I converted PHP&#8217;s <span class="code">mysql_*</span> functions to the <span class="code">mssql_*</span> variety. Unfortunately, MSSQL is not supported in PHP to quite the same extent as MySQL. The function <span class="code">mysql_insert_id()</span> does not exist for MSSQL. Instead, you have to query the database for the last insert ID, something like: <span class="code">&#8220;SELECT @@IDENTITY as insert_id&#8221;</span> in order to get what you want. Also, <span class="code">mysql_affected_rows()</span> becomes <span class="code">mssql_rows_affected()</span>. Not sure why they&#8217;re flip-flopped, but I&#8217;m sure PHP will never change it now.</p>
<p>Anyway, after all that I was able to connect to the database to install WordPress, but clicking the &#8220;Install&#8221; button resulted in thirty-nine pages of syntax errors. Thirty-nine pages! Just from the installation!</p>
<p>I informed those concerned that I didn&#8217;t think porting existing software would work for us considering the time constraints and asked for work to resume on our in-house solution. The response was that porting the blog &#8220;shouldn&#8217;t be expected to be a piece of cake&#8221; and was told to look for another off the shelf solution, because &#8220;there must be others developing a blog for MSSQL&#8221; besides us.</p>
<p>After two hours of searching again, I found a few blog platforms that run on MSSQL. Unfortunately, they require ASP.NET (yuck) and/or cost many thousands of dollars. Just as I was about to leave for the night, I stumbled upon <a href="http://www.geeklog.net/">Geeklog</a>. It&#8217;s written in PHP and supports MySQL and MSSQL.</p>
<p>I installed it at home tonight (on MySQL, of course) and it seems like it should fit our needs. I&#8217;ll give it a go with MSSQL first thing tomorrow morning and try kicking the tires. If they don&#8217;t pop, I&#8217;ll open up the hood and start messing around with the insides.</p>
]]></content:encoded>
			<wfw:commentRss>http://stevelove.org/2008/04/16/crash-course-in-blog-surgery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

