public function connect(): bool
    {
        try {
            $this->checkConnect();
            $this->log('Connect to ' . $this->connect['host']);
            $this->handler = new \PDO(
                $this->connect['type'] . ':host=' . $this->connect['host'] . ';dbname=' . $this->connect['name'],
                $this->connect['user'],
                $this->connect['pass'],
                $this->connect['options']
            );

            foreach ($this->attributes as $attribute => $value) {
                $this->handler->setAttribute($attribute, $value);
            }

            $this->ok();
        } catch (\Exception $e) {
            throw new DbException("Attempt connection to database is failed: {$e->getMessage()}");
        }
        return true;
    }
public function connect(): bool
    {
        try {
            $this->checkConnect();
            $this->log('Connect to ' . $this->connect['host']);
            $this->handler = new \PDO(
                $this->connect['type'] . ':host=' . $this->connect['host'] . ';dbname=' . $this->connect['name'],
                $this->connect['user'],
                $this->connect['pass'],
                $this->connect['options']
            );

            foreach ($this->attributes as $attribute => $value) {
                $this->handler->setAttribute($attribute, $value);
            }

            $this->ok();
        } catch (\Exception $e) {
            throw new DbException("Attempt connection to database is failed: {$e->getMessage()}");
        }
        return true;
    }
public function connect ( ) : bool { try { $ this -> checkConnect ( ) ; $ this -> log ( 'Connect to ' . $ this -> connect [ 'host' ] ) ; $ this -> handler = new \ PDO ( $ this -> connect [ 'type' ] . ':host=' . $ this -> connect [ 'host' ] . ';dbname=' . $ this -> connect [ 'name' ] , $ this -> connect [ 'user' ] , $ this -> connect [ 'pass' ] , $ this -> connect [ 'options' ] ) ; foreach ( $ this -> attributes as $ attribute => $ value ) { $ this -> handler -> setAttribute ( $ attribute , $ value ) ; } $ this -> ok ( ) ; } catch ( \ Exception $ e ) { throw new DbException ( "Attempt connection to database is failed: {$e->getMessage()}" ) ; } return true ; }
Connect to Db

@return bool
@throws DbException
Connect to Db