Resolve db->getquery()->dump() bugs

Although this should work, JF reports that it doesn't.
Merge pull request #901 from Sophist-UK/fix_db-getquery-dump_bugs

Resolve db->getquery()->dump() bugs