Database Improvements

Ongoing work to replace all of TheyWorkForYou's raw queries with nice shiny PDO prepared statements.
Ah, I see, you meant the branch of this PR was rebased to have it there, great, goodo.