Neil Turner's Blog

Blogging about technology and randomness since 2002

Worshipping at the altar of SQL

This morning I said that I would turn off the posting of new comments on all old entries. And I’ve done it already, thanks to SQL. If you want to do this yourself, and are running Movable Type hooked into an SQL database, then read on.


Firstly, you’ll need to be in some environment where you can execute SQL queries. Chances are that if you host offers a MySQL database, you’ll also get phpMyAdmin, which is fine for what we want. If you have shell access to the database you should be able to execute queries that way too.
I use phpMyAdmin, so here’s how I did it. I logged in, selected the ‘mt_entry’ database and then clicked on the ‘SQL’ tab. In the box, I pasted this string:

UPDATE mt_entry SET entry_allow_comments = 2 WHERE entry_id < 1100;

What this string is doing is telling the database to set comments to ‘closed’ for all entries where the entry ID is less than 1100. You can customise this in the following ways:

  1. To turn off comments for all entries, change entry_allow_comments = 2 to read entry_allow_comments = 0. If you want them all open, change the 2 to a 1.
  2. To change which entries are modified, change entry_id < 1100 to another number.

This method is a little crude and specific to what I want, but if you are considering turning off comments for old entries like I am it may save you a lot of time.
Remember that once you have done this, you will need to rebuild the affected entries to hide the comments form.

Comments are closed.