Database Improvements

Ongoing work to replace all of TheyWorkForYou's raw queries with nice shiny PDO prepared statements.
I think this catch should still use the `fatal_error` function, I can't see why this was removed - when the database is down, it is nicer to show a minimalist page with logo than a single text line. This page has actually been seen in the past.