making sure the database is connected

Getting driver name throws exception (see below), when database is not connected. This may happen when extending Query Builder with driver-dependent functionality (LIMIT and OFFSET on Access or SQL Server, for instance).


```
ErrorException [ Fatal Error ]:
Call to a member function getAttribute() on a non-object
```
set_charset() different db types

set_charset() extended to support different db types.
SQLServer encoding setting moved under set_charset() from connect().
Doesn't add "charset=..." when db type is SQLite
Merge pull request #1690 from perdodi/1.8/develop

connect to database when getting driver name