Database Improvements

Ongoing work to replace all of TheyWorkForYou's raw queries with nice shiny PDO prepared statements.
And more house constants in the three queries in this file.