[BUGFIX] Logging PHP errors to sys_log table does not work

Logging PHP errors stopped working after changeset
3e309294309458279eef2adf08af6adb8ed4a867 when the  DatabaseConnection
class was changed.
The changed line tries to determine, if a database connection is
available and only writes the log entry if the connection was
already established.

Resolves: #49645
Releases: 6.1, 6.2
Change-Id: Idee413ed911a8c2d23f034ceadd17c955c98a337
Reviewed-on: https://review.typo3.org/22166
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Jigal van Hemert
Tested-by: Jigal van Hemert