A bit of cleanup

Moved SQL queries to Active Record, re-aligned the PHP as BSD style, returned false on **ALL** queries that return 0 rows.