mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
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
This commit is contained in:
parent
1871f5e2c0
commit
002946350c
1 changed files with 32 additions and 1 deletions
|
@ -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
|
// 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
|
else
|
||||||
{
|
{
|
||||||
// it's not complete, so prepend it onto the next token and continue the loop as usual.
|
// 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.
|
// save memory.
|
||||||
$tokens[$i] = "";
|
$tokens[$i] = "";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue