public function getDatabase($alias, $target = Database::TARGET_MASTER)
    {
        $database = isset($this->_databases[$alias]) ? $this->_databases[$alias] : null;
        if ($target === Database::TARGET_SLAVE) {
            $database = $database->pickSlave();
        }
        return $database;
    }