Refactored get_fields()

Changed get_fields() to use a do..while loop instead of performing a single instance of getting a field and then doing a while loop. This made the code cleaner, but it also allowed for only one field to be put in the field cause of the SELECT statement. Before (though I didn't test it), I believe it would have just segfaulted (because it would've looked for a comma which was not there.)