src/CarteBlanche/Library/StorageEngine/Database.php
protected function _loadAdapter($autoconnect = true)
    {
        $factory = \Library\Factory::create()
            ->factoryName(__CLASS__)
            ->mustImplementAndExtend(array(
                Kernel::DATABASE_ADAPTER_ABSTRACT,
                Kernel::DATABASE_ADAPTER_INTERFACE
            ))
            ->defaultNamespace(Kernel::DATABASE_ADAPTER_DEFAULT_NAMESPACE)
            ->classNameMask(array('%s', '%s'.Kernel::DATABASE_ADAPTER_SUFFIX))
            ;
        $params = array(
            $this, $this->__db_name, $this->__adapter_options
        );
        $this->__adapter = $factory->build($this->__adapter_type, $params);
    /*
        $_adapter_class = '\Lib\DatabaseAdapter\\'.ucfirst($this->__adapter_type);
        if (!\CarteBlanche\App\Loader::classExists($_adapter_class)) {
            $_adapter_class .= 'Adapter';
        }
        if (\CarteBlanche\App\Loader::classExists($_adapter_class)) {
            try {
                $this->__adapter = new $_adapter_class(
                    $this, CarteBlanche::getPath('db_path').$this->__db_name, $this->__adapter_options
                );
            } catch ( \Exception $e ) {
                throw new \RuntimeException(
                    sprintf('An error occurred while trying to load Database Adapter "%s"!', $_adapter_class)
                );
            }
            if (!($this->__adapter instanceof \Lib\DatabaseAdapter\AbstractDatabaseAdapter)) {
                throw new \DomainException(
                    sprintf('A Database Adapter must extend the "\Lib\DatabaseAdapter\AbstractDatabaseAdapter" class (got "%s")!', $_adapter_class)
                );
            }
            if (!($this->__adapter instanceof \Lib\DatabaseAdapter\DatabaseAdapterInterface)) {
                throw new \DomainException(
                    sprintf('A Database Adapter must implements the "\Lib\DatabaseAdapter\DatabaseAdapterInterface" interface (got "%s")!', $_adapter_class)
                );
            }
        } else {
            throw new \RuntimeException(
                sprintf('Database adapter for type "%s" doesn\'t exist!', $this->__adapter_type)
            );
        }
    */
        if (true===$autoconnect) $this->connect();
        return $this;
    }
protected function _loadAdapter($autoconnect = true)
    {
        $factory = \Library\Factory::create()
            ->factoryName(__CLASS__)
            ->mustImplementAndExtend(array(
                Kernel::DATABASE_ADAPTER_ABSTRACT,
                Kernel::DATABASE_ADAPTER_INTERFACE
            ))
            ->defaultNamespace(Kernel::DATABASE_ADAPTER_DEFAULT_NAMESPACE)
            ->classNameMask(array('%s', '%s'.Kernel::DATABASE_ADAPTER_SUFFIX))
            ;
        $params = array(
            $this, $this->__db_name, $this->__adapter_options
        );
        $this->__adapter = $factory->build($this->__adapter_type, $params);
    /*
        $_adapter_class = '\Lib\DatabaseAdapter\\'.ucfirst($this->__adapter_type);
        if (!\CarteBlanche\App\Loader::classExists($_adapter_class)) {
            $_adapter_class .= 'Adapter';
        }
        if (\CarteBlanche\App\Loader::classExists($_adapter_class)) {
            try {
                $this->__adapter = new $_adapter_class(
                    $this, CarteBlanche::getPath('db_path').$this->__db_name, $this->__adapter_options
                );
            } catch ( \Exception $e ) {
                throw new \RuntimeException(
                    sprintf('An error occurred while trying to load Database Adapter "%s"!', $_adapter_class)
                );
            }
            if (!($this->__adapter instanceof \Lib\DatabaseAdapter\AbstractDatabaseAdapter)) {
                throw new \DomainException(
                    sprintf('A Database Adapter must extend the "\Lib\DatabaseAdapter\AbstractDatabaseAdapter" class (got "%s")!', $_adapter_class)
                );
            }
            if (!($this->__adapter instanceof \Lib\DatabaseAdapter\DatabaseAdapterInterface)) {
                throw new \DomainException(
                    sprintf('A Database Adapter must implements the "\Lib\DatabaseAdapter\DatabaseAdapterInterface" interface (got "%s")!', $_adapter_class)
                );
            }
        } else {
            throw new \RuntimeException(
                sprintf('Database adapter for type "%s" doesn\'t exist!', $this->__adapter_type)
            );
        }
    */
        if (true===$autoconnect) $this->connect();
        return $this;
    }
Load the database adapter

@param bool $autoconnect Build the connexion after adapter construction
@return self $this for method chaining