_setDbAdapter() - set the database adapter to be used for quering

@param Zend_Db_Adapter_Abstract
@throws Zend_Auth_Adapter_Exception
@return Zend_Auth_Adapter_DbTable
480344
protected function _setDbAdapter(Zend_Db_Adapter_Abstract $zendDb = null)
    {
        $this->_zendDb = $zendDb;

        /**
         * If no adapter is specified, fetch default database adapter.
         */
        if(null === $this->_zendDb) {
            require_once 'Zend/Db/Table/Abstract.php';
            $this->_zendDb = Zend_Db_Table_Abstract::getDefaultAdapter();
            if (null === $this->_zendDb) {
                require_once 'Zend/Auth/Adapter/Exception.php';
                throw new Zend_Auth_Adapter_Exception('No database adapter present');
            }
        }

        return $this;
    }
107687
public function getAdapter($name = null)
    {
        if (null === $name) {
            $name = $this->getDefaultDatasource();
        }
        if (!isset($this->adapters[$name])) {
            if (!isset($this->adapterClasses[$name])) {
                throw new AdapterException(sprintf('No adapter class defined for datasource "%s"', $name));
            }
            $this->adapters[$name] = AdapterFactory::create($this->adapterClasses[$name]);
        }

        return $this->adapters[$name];
    }
442925
public function getConnection()
    {
        // if we already have a PDO object, no need to re-connect.
        if ($this->_connection) {
            return $this->_connection;
        }

        $this->_pdoType = "sqlsrv";
        // get the dsn first, because some adapters alter the $_pdoType
        //$dsn = $this->_dsn();

        // check for PDO extension
        if (!extension_loaded('pdo')) {
            /**
             * @see Zend_Db_Adapter_Exception
             */
            throw new \Zend_Db_Adapter_Exception('The PDO extension is required for this adapter but the extension is not loaded');
        }

        // check the PDO driver is available
        if (!in_array($this->_pdoType, PDO::getAvailableDrivers())) {
            /**
             * @see Zend_Db_Adapter_Exception
             */
            throw new \Zend_Db_Adapter_Exception('The ' . $this->_pdoType . ' driver is not currently installed');
        }

        // create PDO connection
        $q = $this->_profiler->queryStart('connect', Zend_Db_Profiler::CONNECT);

        // add the persistence flag if we find it in our config array
        if (isset($this->_config['persistent']) && ($this->_config['persistent'] == true)) {
            $this->_config['driver_options'][PDO::ATTR_PERSISTENT] = true;
        }

        try {
            $serverName = $this->_config["host"];
            $database   = $this->_config["dbname"];
            if (is_null($database)) {
                $database = 'master';
            }
            $uid = $this->_config['username'];
            $pwd = $this->_config['password'];
            if ($this->_config["port"] != "") {
                $serverName = $serverName . "," . $this->_config["port"];
            }

            $this->_connection = new PDO("sqlsrv:$serverName", $uid, $pwd, array('Database' => $database));

            if ($this->_connection === false) {
                die(self::FormatErrors(sqlsrv_errors()));
            }

            /*
            $this->_connection = new PDO(
                $dsn,
                $this->_config['username'],
                $this->_config['password'],
                $this->_config['driver_options']
            );
            */

            $this->_profiler->queryEnd($q);

            // set the PDO connection to perform case-folding on array keys, or not
            $this->_connection->setAttribute(PDO::ATTR_CASE, $this->_caseFolding);
            $this->_connection->setAttribute(PDO::SQLSRV_ENCODING_UTF8, true);

            // always use exceptions.
            $this->_connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

            return $this->_connection;
        } catch (PDOException $e) {
            /**
             * @see Zend_Db_Adapter_Exception
             */
            throw new \Zend_Db_Adapter_Exception($e->getMessage(), $e->getCode(), $e);
        }
    }
1037353
public function setAdapter($options = null)
    {
        if (is_string($options)) {
            $adapter = $options;
        } elseif (isset($options['adapter'])) {
            $adapter = $options['adapter'];
            unset($options['adapter']);
        } else {
            $adapter = 'BlockCipher';
        }

        if (!is_array($options)) {
            $options = [];
        }

        if (class_exists('Zend\Filter\Encrypt\\' . ucfirst($adapter))) {
            $adapter = 'Zend\Filter\Encrypt\\' . ucfirst($adapter);
        } elseif (!class_exists($adapter)) {
            throw new Exception\DomainException(
                sprintf(
                    '%s expects a valid registry class name; received "%s", which did not resolve',
                    __METHOD__,
                    $adapter
                )
            );
        }

        $this->adapter = new $adapter($options);
        if (!$this->adapter instanceof Encrypt\EncryptionAlgorithmInterface) {
            throw new Exception\InvalidArgumentException(
                "Encoding adapter '" . $adapter
                . "' does not implement Zend\\Filter\\Encrypt\\EncryptionAlgorithmInterface"
            );
        }

        return $this;
    }
401734
static public function isAvailableAdapter($adapter)
    {
        $adapter = strtolower($adapter);
        $result  = false;
        $type    = null;

        $pdoAdapters = (class_exists('Pdo', false)) ? \PDO::getAvailableDrivers() : array();
        if (strpos($adapter, 'pdo_') !== false) {
            $type    = substr($adapter, 4);
            $adapter = 'pdo';
        }

        switch ($adapter) {
            case 'mysql':
            case 'mysqli':
                $result = (class_exists('mysqli', false));
                break;
            case 'oci':
            case 'oracle':
                $result = (function_exists('oci_connect'));
                break;
            case 'pdo':
                $result = (in_array($type, $pdoAdapters));
                break;
            case 'pgsql':
                $result = (function_exists('pg_connect'));
                break;
            case 'sqlite':
                $result = (class_exists('Sqlite3', false));
                break;
            case 'sqlsrv':
                $result = (function_exists('sqlsrv_connect'));
                break;
        }

        return $result;
    }
1106520
public function getAdapter()
    {
        if (is_null($this->_adapter)) {
            $key = "db_{$this->configName}";
            $this->setAdapter($this->getContainer()->get($key));
        }
        return $this->_adapter;
    }
105843
public function createAdminAdapter(DatabaseConnection $db) {
		$driver = $db->getInfo()->getDriver();
		switch ($driver) {
			case 'mysql':
			return new MysqlAdminAdapter($db);

			case 'pgsql':
			return new PgsqlAdminAdapter($db);

			case 'sqlite':
			return new SqliteAdminAdapter($db);

			default:
			throw new InvalidArgumentException("Unsupported driver: $driver");
		}
	}
1349878
public function getAdapter()
    {
        if (null == $this->adapter) {
            $className = $this->getEntityDescriptor()->className();
            $repository = Orm::getRepository($className);
            $this->setAdapter($repository->getAdapter());
        }
        return $this->adapter;
    }
185965
public function getAdapter()
    {
        if (isset($this->adapter)) {
            return $this->adapter;
        }
        if (isset($this->options['connection'])) {
            if (!($this->options['connection'] instanceof \PDO)) {
                throw new \RuntimeException('The specified connection is not a PDO instance');
            }

            $this->options['connection']->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
            $this->options['adapter'] = $this->options['connection']->getAttribute(\PDO::ATTR_DRIVER_NAME);
        }
        if (!isset($this->options['adapter'])) {
            throw new \RuntimeException('No adapter was specified for environment: ' . $this->getName());
        }

        $factory = AdapterFactory::instance();
        $adapter = $factory
            ->getAdapter($this->options['adapter'], $this->options);

        // Automatically time the executed commands
        $adapter = $factory->getWrapper('timed', $adapter);

        if (isset($this->options['wrapper'])) {
            $adapter = $factory
                ->getWrapper($this->options['wrapper'], $adapter);
        }

        if ($this->getCommand()) {
            $adapter->setCommand($this->getCommand());
        }

        // Use the TablePrefixAdapter if table prefix/suffixes are in use
        if ($adapter->hasOption('table_prefix') || $adapter->hasOption('table_suffix')) {
            $adapter = AdapterFactory::instance()
                ->getWrapper('prefix', $adapter);
        }

        $this->setAdapter($adapter);

        return $adapter;
    }
693728
public function getAdapter()
    {
        if (is_null($this->adapter) || ! $this->adapter instanceof AdapterInterface) {
            $class = '\\Wslim\\Db\Adapter\\' . $this->options['adapter'] . 'Adapter';
            if (!class_exists($class)) {
                throw new DbException('database adapter is not exists:' . $class);
            }
            
            $this->adapter  =   new $class($this->options);
        }
        
        return $this->adapter;
    }
47702
public static function createAdapterFromZendDb2(\Zend\Db\Adapter\Adapter $zendAdapter)
    {
        return new \Soluble\DbWrapper\Adapter\Zend\ZendDb2Adapter($zendAdapter);
    }
1352958
public function setAdapterOptions($options)
    {
        if (!is_array($options) && !$options instanceof AbstractOptions) {
            throw new Exception\InvalidArgumentException(sprintf(
                '"%s" expects an array or a valid instance of "%s"; received "%s"',
                __METHOD__,
                'Zend\Stdlib\AbstractOptions',
                is_object($options) ? get_class($options) : gettype($options)
            ));
        }
        $this->adapterOptions = $options;
        $this->options = $options;

        return $this;
    }
1244011
public function setAdapter($adapter)
    {
        if (is_string($adapter)) {
            if (class_exists($adapter)) {
                $class = $adapter;
            } elseif (class_exists("PSchwisow\\Phergie\\Plugin\\UrlShorten\\Adapter\\{$adapter}")) {
                $class = "PSchwisow\\Phergie\\Plugin\\UrlShorten\\Adapter\\{$adapter}";
            } else {
                throw new \InvalidArgumentException("Class not found: '$adapter'");
            }
            $adapter = new $class;
        }

        if (!$adapter instanceof AbstractAdapter) {
            throw new \InvalidArgumentException(
                'Shortener service must extend PSchwisow\Phergie\Plugin\UrlShorten\Adapter\AbstractAdapter'
            );
        }
        $this->adapter = $adapter;

    }
511203
public function getAdapter()
    {
        if (empty($this->adapter)) {
            $user = $this->getUser();
            $sessionDataStored = $user->getAuthSession($this->providerKey);
            $hybridAuth = $this->getHybridAuth();
            if (!empty($sessionDataStored)) {
                $hybridAuth->restoreSessionData($sessionDataStored);
            }
            $adapter = $hybridAuth->authenticate($this->providerKey);
            $sessionData    = $hybridAuth->getSessionData();
            if ($sessionData != $sessionDataStored) {
                $user->updateAuthSession($this->providerKey, $sessionData);
            }
            $this->adapter = $adapter;
        }
        return $this->adapter;
    }
757433
protected function buildDatabase(): DatabaseAdapter {
		$database = new SqliteDatabase($this->determineDbCharset(), 
				$this->getPersistedMetaEntities(), $this->determineDbAttrs());
		
		foreach ($database->getMetaEntities() as $metaEntity) {
			if (!$metaEntity instanceof Table) continue;
			
			$this->metaEntityBuilder->applyIndexesForTable(
					SqliteDatabase::FIXED_DATABASE_NAME, $metaEntity);
		}
		
		return $database;
	}
721129
@Override
    public void setAdapter(SpinnerAdapter adapter) {
        if (null != mAdapter) {
            mAdapter.unregisterDataSetObserver(mDataSetObserver);
            resetList();
        }

        mAdapter = adapter;

        mOldSelectedPosition = INVALID_POSITION;
        mOldSelectedRowId = INVALID_ROW_ID;

        if (mAdapter != null) {
            mOldItemCount = mItemCount;
            mItemCount = mAdapter.getCount();
            checkFocus();

            mDataSetObserver = new AdapterDataSetObserver();
            mAdapter.registerDataSetObserver(mDataSetObserver);

            int position = mItemCount > 0 ? 0 : INVALID_POSITION;

            setSelectedPositionInt(position);
            setNextSelectedPositionInt(position);

            if (mItemCount == 0) {
                // Nothing selected
                checkSelectionChanged();
            }

        } else {
            checkFocus();
            resetList();
            // Nothing selected
            checkSelectionChanged();
        }

        requestLayout();
    }
105171
public function setAdapter($adapter)
    {
        if (\is_callable($adapter)) {
            $adapter = \call_user_func($adapter, $this->container);
        }

        $this->adapter = $adapter;
    }