Ensure Database is set in Tracker

Perform an added check to ensure the database is connected prior to returning it. 
Corrects an error encountered in bulk tracking with PIWIK_TRACKER_MODE set.