I am facing the same problem. I have added that function in db.php file but still showing that error.
Notice: SharDB was called incorrectly. SharDB must set a database connection for use with escaping.
db-settigs.php settings
$shardb_hash_length = 1;
$shardb_prefix = ‘old_wordpress_’;
$shardb_dataset = ‘wordpress’;
$enable_home_db = true;
$shardb_local_db = true;