Databases category archive

Comment cleanup

November 1st, 2006 | Filed under Announcements, Code snippets, WordPress, SQL

UPDATE wp_posts SET comment_status='closed';
DELETE FROM wp_comments;

Sorry folks, comments here on Spun are now disabled - the spam got the better of me. I know, I know, there are plugins to help manage it, but I simply don’t have the time. Email me your thoughts on posts to ginatrapani at gmail.


Tags: Database schemas

December 4th, 2005 | Filed under Databases, Reference, Schemas, SQL

Somewhat old news that I found myself looking up tonight: database schemas for tags, ranging from stuffing keywords into a giant field to 2NF to 3NF.

Being the good database girl that I am, I tend toward third normal form (the last example, which involves 3 tables), but enforcing cascading deletes to trash orphaned tags would be a lot of more work for the app. At the other end of the spectrum, the single table solution seems insane (aren’t LIKE’s generally a no-no?), but at one point when Matt suggested this at Kinja and I consequently almost passed out, after some debate I realized there might be times this would fit best. (Note to self: there is never One True Way.) Maybe in media res, and the 2 table solution is best.

Anyway, a good reference for Web 2.0 taggy apps getting built out there.

Tags: Database schemas [Philipp Keller]

View live site referers

September 6th, 2005 | Filed under PHP, MySQL, Essential Tools, Traffic stats

Programmer Dean Allen’s free PHP/MySQL app, Refer, displays live real-time referring URLs to your web site.

Of course, one could just watch one’s site logs to get an idea of who’s clicking in from where. But Refer filters out certain types of files (CSS, JS, etc), referers from your own domain, and can exclude certain directories, too. (Like, I don’t want to see any referers generated while I’m working on a post in WordPress.)

I’ve used Refer for several months now on my other site, and besides occassional referer spam problems, it’s a fantastic way to see immediately if your site is getting a whole lot of traffic from fresh links.

The downside of Refer is that it requires a database insert on EVERY request for pages for which you want referers recorded. This can slow things down considerably, and perhaps give your conservative performance-concerned sysadmin indigestion. Refer uses this neat .htaccess line which automatically adds the PHP script to the end of each page for processing:

php_value auto_prepend_file /www/ginatrapani/refer/refer.php

Not sure how long I’ll keep this unpassworded, but here’s Spun’s installation of Refer so you can check out how it works yourself..

Refer 2.1 [Textism]

iTunes Library reports

August 31st, 2005 | Filed under PHP, Code snippets, XML, MySQL

Developer Alex King’s released a PHP/MySQL app that imports your iTunes library and displays reports like your top rated artists based on number of songs.

The code imports iTunes’ Library.xml into 3 MySQL tables using PHP 5’s XML libraries, like this:

Even Alex says that’s “an ugly hack.” What’s the better way to handle it without the output buffering?

Either way, I’ve posted my iTunes library reports using Alex’s app.

alexking.org: Blog > iTunes Stats [Alex King]