For more than a year now, my intention has been to start posting things I’ve learned or things I’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’s just get started then.
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’ve been using for about four years now and with which I’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.
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.
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 … 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.
Sigh.
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 LIMIT and converted it to TOP for MSSQL. Microsoft would do well to add LIMIT to its syntax. Compare the following:
MySQL:
"SELECT id,title,post FROM table_name WHERE category_name = 'category' ORDER BY DESC LIMIT 4,10"
MSSQL:
"SELECT TOP 10 id,title,post FROM table_name WHERE category_name = 'category' AND id NOT IN (SELECT TOP 4 id FROM table_name WHERE category_name = 'category' ORDER BY DESC) ORDER BY DESC"
After changing those, I converted PHP’s mysql_* functions to the mssql_* variety. Unfortunately, MSSQL is not supported in PHP to quite the same extent as MySQL. The function mysql_insert_id() does not exist for MSSQL. Instead, you have to query the database for the last insert ID, something like: “SELECT @@IDENTITY as insert_id” in order to get what you want. Also, mysql_affected_rows() becomes mssql_rows_affected(). Not sure why they’re flip-flopped, but I’m sure PHP will never change it now.
Anyway, after all that I was able to connect to the database to install Wordpress, but clicking the “Install” button resulted in thirty-nine pages of syntax errors. Thirty-nine pages! Just from the installation!
I informed those concerned that I didn’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 “shouldn’t be expected to be a piece of cake” and was told to look for another off the shelf solution, because “there must be others developing a blog for MSSQL” besides us.
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 Geeklog. It’s written in PHP and supports MySQL and MSSQL.
I installed it at home tonight (on MySQL, of course) and it seems like it should fit our needs. I’ll give it a go with MSSQL first thing tomorrow morning and try kicking the tires. If they don’t pop, I’ll open up the hood and start messing around with the insides.
Subscribe to the feed
Subscribe by email