Fixes 801687 - Upgrade bouncer database handling

* Implements PDO instead of old mysql_* API
* Adds error handling, raises exceptions on failure
* Adds new tests for new database layer which all pass (YAY!)
* Fixes older tests that rely on old SDO database object.
* Creates mock Memcache object and interface for caching layer.