From 002946350c6beb8cd773cd0f8f8228fb2e335617 Mon Sep 17 00:00:00 2001 From: the_systech Date: Mon, 24 Sep 2001 19:48:11 +0000 Subject: Added remove_comments function for processing mssql and postgress(/**/) style comments... also modified split_sql_file to rejoin statements using $delimiter instead of a hardcoded ";" git-svn-id: file:///svn/phpbb/trunk@1070 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/sql_parse.php | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/sql_parse.php') diff --git a/phpBB/includes/sql_parse.php b/phpBB/includes/sql_parse.php index cc94437762..dcb0482e04 100644 --- a/phpBB/includes/sql_parse.php +++ b/phpBB/includes/sql_parse.php @@ -28,6 +28,37 @@ * \***************************************************************************/ +// +// remove_comments will strip the sql comment lines out of an uploaded sql file +// specifically for mssql and postgres type files in the install.... +// +function remove_comments($sql) +{ + $lines = explode("\n", $sql); + + // try to keep mem. use down + $sql = ""; + $linecount = count($lines); + $output = ""; + $in_comment = false; + for($i = 0; $i < $linecount; $i++) + { + if(ereg("^\/\*", $lines[$i]) + { + $in_comment = true; + } + if(ereg("\*\/$", $lines[$i]) + { + $in_comment = false; + } + if(!$in_comment) + { + $output .= $lines[$i] . "\n"; + } + $lines[$i] = ''; + } + return $output; +} // // remove_remarks will strip the sql comment lines out of an uploaded sql file // @@ -103,7 +134,7 @@ function split_sql_file($sql, $delimiter) else { // it's not complete, so prepend it onto the next token and continue the loop as usual. - $tokens[$i + 1] = $tokens[$i] . ";" . $tokens[$i + 1]; + $tokens[$i + 1] = $tokens[$i] . $delimiter . $tokens[$i + 1]; // save memory. $tokens[$i] = ""; } -- cgit v1.2.1