MySQL
Sorting numeric values stored in character fields with views.module
I spent a good chunk of time this morning trying to figure out how to get the views module to sort a character field with numeric data correctly. The audio module has a normalized table of meta-data meaning that there's one column for the tag name and one for the value. The value is stored as a character string which causes problem when sorting numeric data like the track numbers or years. If you've got a SELECT value FROM audio_metadata ORDER BY value that returns the range of numbers 1...13 it ends up sorted as 1,10,11,12,13,2,3...9. The trick as I discovered is to add zero to the field to coerce it to a numeric value: SELECT value + 0 AS v FROM audio_metadata ORDER BY v.
The problem then is to figure out how to get the views module to generate this bit SQL to get the sorting right. The solution I came upon is when defining the field set 'notafield' to TRUE and provide a 'query_handler' to generate the correct SQL. I've included the relevant parts of the audio module below to demonstrate how it works. You can see the complete code here.
Installing MySQL Server on Windows
This page provides instructions for a Drupal developer who'd like to install MySQL 5 on their desktop computer. The instructions assume that you're running a recent version of Windows (NT, 2000, XP, or 2003). Older version like Windows 95, 98 and Me will not be addressed.
Setup Apache and MySQL
To run the website, we'll install a database, webserver and scripting language. You'll need to install the following ports and their dependencies:
- databases/mysql51-server - MySQL server
- www/apache22 - Webserver
- lang/php5 - PHP
Setup Drupal 5
The station's website will be build using Drupal an extremely powerful, open source content managment system written in PHP.
Drupal uses some PHP functions that require the installation of additional ports. You'll need:
- devel/php5-pcre - Perl regular expressions.
- textproc/php5-xml - XML parsing.
- databases/php5-mysqli - MySQL support for PHP.
- www/php5-session - Session support.
- graphics/php5-gd - Image handing. Optional, some modules need it.
- converters/php5-mbstring - Unicode support. Optional, but Drupal prefers that it be installed.
HOWTO: A FreeBSD radio station web server
This HOWTO walks you through the process of building a FreeBSD server to put a radio station on the internet. When you're finished you'll have a:
- Apache2 web server
- MySQL 5 database server
- Icecast2 MP3 webstream
- Drupal based website with:
- Program schedule
- MP3 Archive of broadcasts
This is the setup pioneered for use by KPSU, a college radio station in Portland Oregon, to stream and archive our broadcasts on the internet. I've released the code as the Drupal Audio and Station modules. You can find a list of some of the websites using the Station module.
All the software is free and open source. The only thing you've got to pay for is your time and hosting. While the details are FreeBSD specific, the general setup can be used for any UNIX like OS.
First, setup FreeBSD, use the handbook for that. Sorry to be so vague on details but that part of the setup is going to vary greatly depending on your hardware. The handbook will do a better job of explaining it than I could hope to do.
Once you've got a running server, start making your way through the following pages:






