diff options
author | the_systech <the_systech@users.sourceforge.net> | 2001-09-24 19:48:11 +0000 |
---|---|---|
committer | the_systech <the_systech@users.sourceforge.net> | 2001-09-24 19:48:11 +0000 |
commit | 002946350c6beb8cd773cd0f8f8228fb2e335617 (patch) | |
tree | 6b90af4244fb5281cb0bca9c1d9ec8b2080d9cf7 | |
parent | 1871f5e2c0e5c667e4b9b11a316f0db64d728693 (diff) | |
download | forums-002946350c6beb8cd773cd0f8f8228fb2e335617.tar forums-002946350c6beb8cd773cd0f8f8228fb2e335617.tar.gz forums-002946350c6beb8cd773cd0f8f8228fb2e335617.tar.bz2 forums-002946350c6beb8cd773cd0f8f8228fb2e335617.tar.xz forums-002946350c6beb8cd773cd0f8f8228fb2e335617.zip |
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
-rw-r--r-- | phpBB/includes/sql_parse.php | 33 |
1 files changed, 32 insertions, 1 deletions
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 @@ -29,6 +29,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 // function remove_remarks($sql) @@ -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] = ""; } |