DatabaseBase::query - autogenerate $fname if not passed

@Wikia/platform-team

Resolves https://wikia-inc.atlassian.net/browse/PLATFORM-404 (@nmonterroso)

This will make #4752 not needed