Ensure db connection before changing cache state

When trying to upgrade from 7.0.0 to 7.0.2, the manual upgrade path
(e.g. ` sudo -u www-data /usr/bin/php5 ./occ upgrade`) exits with the
following fatal error:

```
/var/www/owncloud# php occ upgrade
PHP Fatal error:  Call to a member function
  disableQueryStatementCaching() on a non-object in
  /var/www/owncloud/lib/private/db.php on line 423
```

This is caused by the self::$connection static variable having not
been initialized at the point of call. Adding a self::connect() fixes
the issue.

See https://forum.owncloud.org/viewtopic.php?f=29&t=23398&p=68556#p68556
Merge pull request #10761 from canadaduane/fix_occ_upgrade

Ensure db connection before changing cache state