Refactor building of select string

Refactored building of select string to use dynamic variables to reduce
code.
Update .gitignore
Refactor database query into a class
Removed unwanted values from output fields

Removed values from the results when the field was not specified for
output. When creating the query, we added ID fields to the select list.
So we needed to remove those ID fields if they weren't requested by the
API caller.