public function setFetchOptions( $fetchOptions )
    {

        // set fetchOptions
        if( $fetchOptions === null ) {
            return $this->fetchOptions;
        }

        if( !is_integer($fetchOptions) ) {
            throw new BadTypeException( $fetchOptions, 'int' );
        }

        $fetchOptions += $fetchOptions & ( self::TYPE_DETECT | self::TYPE_AGNOSTIC ) ? 0 : self::TYPE_DEFAULT;
        $fetchOptions += $fetchOptions & ( self::FLATTEN_IF_POSSIBLE | self::FLATTEN_PREVENT ) ? 0 : self::FLATTEN_DEFAULT;
        $fetchOptions += $fetchOptions & ( self::STYLE_ASSOC | self::STYLE_NUM ) ? 0 : self::STYLE_DEFAULT;
        $fetchOptions += $fetchOptions & ( self::FETCH_SINGLE | self::FETCH_MULTIPLE ) ? 0 : self::FETCH_DEFAULT;
        $fetchOptions += $fetchOptions & ( self::CACHE | self::CACHE_NOT ) ? 0 : self::CACHE_DEFAULT;

        // flatten
        $flatten = (bool) ( $fetchOptions & self::FLATTEN_IF_POSSIBLE ) && ( $this->numFields() === 1 );

        $this->buildFetchCallback( $fetchOptions, $flatten );

        $this->fetchOptions = $fetchOptions;

        return $this;
    }