lib/SqlFormatter.php
public static function removeComments($string)
    {
        $result = '';

        $tokens = self::tokenize($string);

        foreach ($tokens as $token) {
            // Skip comment tokens
            if ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_COMMENT || $token[self::TOKEN_TYPE] === self::TOKEN_TYPE_BLOCK_COMMENT) {
                continue;
            }

            $result .= $token[self::TOKEN_VALUE];
        }
        $result = self::format( $result,false);

        return $result;
    }
public static function removeComments($string)
    {
        $result = '';

        $tokens = self::tokenize($string);

        foreach ($tokens as $token) {
            // Skip comment tokens
            if ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_COMMENT || $token[self::TOKEN_TYPE] === self::TOKEN_TYPE_BLOCK_COMMENT) {
                continue;
            }

            $result .= $token[self::TOKEN_VALUE];
        }
        $result = self::format( $result,false);

        return $result;
    }
public static function removeComments ( $ string ) { $ result = '' ; $ tokens = self :: tokenize ( $ string ) ; foreach ( $ tokens as $ token ) { // Skip comment tokens if ( $ token [ self :: TOKEN_TYPE ] === self :: TOKEN_TYPE_COMMENT || $ token [ self :: TOKEN_TYPE ] === self :: TOKEN_TYPE_BLOCK_COMMENT ) { continue ; } $ result .= $ token [ self :: TOKEN_VALUE ] ; } $ result = self :: format ( $ result , false ) ; return $ result ; }
Remove all comments from a SQL string

@param String $string The SQL string

@return String The SQL string without comments
Remove all comments from a SQL string