Microweber\Utils\Database::remove_comments_from_sql_string PHP Method

remove_comments_from_sql_string() public method

Will strip the sql comment lines out of an given sql string.
public remove_comments_from_sql_string ( $output ) : string
$output the SQL string with comments
return string $output the SQL string without comments
    public function remove_comments_from_sql_string($output)
    {
        $lines = explode("\n", $output);
        $output = '';
        $linecount = count($lines);
        $in_comment = false;
        for ($i = 0; $i < $linecount; ++$i) {
            if (preg_match("/^\\/\\*/", preg_quote($lines[$i]))) {
                $in_comment = true;
            }
            if (!$in_comment) {
                $output .= $lines[$i] . "\n";
            }
            if (preg_match("/\\*\\/\$/", preg_quote($lines[$i]))) {
                $in_comment = false;
            }
        }
        unset($lines);
        return $output;
    }