public function get( $connection, $cache = true )
    {

        if( !is_string( $connection ) ) {
            throw new BadTypeException( $connection, 'string' );
        }

        // use the multiton
        if( !isset( $this->instances[$connection] ) or !$cache ) {

            if( !isset( $this->connectionSettings[$connection]) ) {
                throw new UnknownNamedConnectionException( $connection );
            }

            $resource = new Resource( $this->connectionSettings[$connection], $this );

            if( $cache ) {
                $this->instances[$connection] = $resource;
            }

        // get the resource from the multiton
        } else {
            $resource = $this->instances[$connection];
        }

        return new Pg( $resource, $connection );
    }
public function get( $connection, $cache = true )
    {

        if( !is_string( $connection ) ) {
            throw new BadTypeException( $connection, 'string' );
        }

        // use the multiton
        if( !isset( $this->instances[$connection] ) or !$cache ) {

            if( !isset( $this->connectionSettings[$connection]) ) {
                throw new UnknownNamedConnectionException( $connection );
            }

            $resource = new Resource( $this->connectionSettings[$connection], $this );

            if( $cache ) {
                $this->instances[$connection] = $resource;
            }

        // get the resource from the multiton
        } else {
            $resource = $this->instances[$connection];
        }

        return new Pg( $resource, $connection );
    }
public function get ( $ connection , $ cache = true ) { if ( ! is_string ( $ connection ) ) { throw new BadTypeException ( $ connection , 'string' ) ; } // use the multiton if ( ! isset ( $ this -> instances [ $ connection ] ) or ! $ cache ) { if ( ! isset ( $ this -> connectionSettings [ $ connection ] ) ) { throw new UnknownNamedConnectionException ( $ connection ) ; } $ resource = new Resource ( $ this -> connectionSettings [ $ connection ] , $ this ) ; if ( $ cache ) { $ this -> instances [ $ connection ] = $ resource ; } // get the resource from the multiton } else { $ resource = $ this -> instances [ $ connection ] ; } return new Pg ( $ resource , $ connection ) ; }
Get the singleton pg connection
@param string $connection
@param boolean $cache
@return \Bond\Pg
Get the singleton pg connection