From cdc1597550cd76aecf67c1f6d254e398a1cb8396 Mon Sep 17 00:00:00 2001 From: natec Date: Mon, 24 Sep 2001 21:50:04 +0000 Subject: Even speedier version (at least 15 times faster) of split_sql_file(). wheeeeee. git-svn-id: file:///svn/phpbb/trunk@1072 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/sql_parse.php | 51 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/sql_parse.php') diff --git a/phpBB/includes/sql_parse.php b/phpBB/includes/sql_parse.php index dcb0482e04..8f8a52b8f9 100644 --- a/phpBB/includes/sql_parse.php +++ b/phpBB/includes/sql_parse.php @@ -101,7 +101,8 @@ function split_sql_file($sql, $delimiter) { // Split up our string into "possible" SQL statements. $tokens = explode($delimiter, $sql); - // try to save memory. + + // try to save mem. $sql = ""; $output = array(); @@ -133,11 +134,51 @@ 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] . $delimiter . $tokens[$i + 1]; - // save memory. + // incomplete sql statement. keep adding tokens until we have a complete one. + // $temp will hold what we have so far. + $temp = $tokens[$i] . $delimiter; + // save memory.. $tokens[$i] = ""; - } + + // Do we have a complete statement yet? + $complete_stmt = false; + + for ($j = $i + 1; (!$complete_stmt && ($j < $token_count)); $j++) + { + // This is the total number of single quotes in the token. + $total_quotes = preg_match_all("/'/", $tokens[$j], $matches); + // Counts single quotes that are preceded by an odd number of backslashes, + // which means they're escaped quotes. + $escaped_quotes = preg_match_all("/(?