encapsulated database query, for using php easily