SMWSql3SmwIds::getDatabaseIdAndSort raise exception for when smw_object_...

...ids is inaccessible

For details, see #158.

- Use SMW\MediaWiki\Database instead of $db = wfGetDB( DB_SLAVE );
- Use tableExistsCache to avoid that on each request $this->query( "SELECT 1 FROM $table ... ) is called