reduced db.php to a single function in query.php