Fixed some db querying syntax for the move to 7