46 $sql_len = strlen(
$sql);
50 for (
$i = 0;
$i < $sql_len; ++
$i) {
54 $i = strpos(
$sql, $string_start,
$i);
59 if ($string_start ==
'`' ||
$sql[
$i - 1] !=
'\\') {
65 $escaped_backslash =
false;
67 $escaped_backslash = !$escaped_backslash;
70 if ($escaped_backslash) {
82 $ret[] = substr(
$sql, 0,
$i);
83 $sql = ltrim(substr(
$sql, min(
$i + 1, $sql_len)));
84 $sql_len = strlen(
$sql);
91 if (($char ==
'"') || ($char ==
'\'') || ($char ==
'`')) {
93 $string_start = $char;
95 if ($char ==
'#' || ($char ==
' ' &&
$i > 1 &&
$sql[
$i - 2] .
$sql[
$i - 1] ==
'--')) {
96 $start_of_comment = ((
$sql[
$i] ==
'#') ?
$i :
$i - 2);
97 $end_of_comment = (strpos(
' ' .
$sql,
"\012",
$i + 2)) ? strpos(
' ' .
$sql,
"\012",
$i + 2)
98 : strpos(
' ' .
$sql,
"\015",
$i + 2);
99 if (!$end_of_comment) {
102 $sql = substr(
$sql, 0, $start_of_comment) . ltrim(substr(
$sql, $end_of_comment));
103 $sql_len = strlen(
$sql);
112 if (!empty(
$sql) && trim(
$sql) !=
'') {
128 $pattern =
"/^(INSERT[\s]+INTO|CREATE[\s]+TABLE|ALTER[\s]+TABLE|UPDATE)(\s)+([`]?)([^`\s]+)\\3(\s)+/siU";
129 $pattern2 =
"/^(DROP TABLE)(\s)+([`]?)([^`\s]+)\\3(\s)?$/siU";
130 if (preg_match($pattern,
$query, $matches)
131 || preg_match($pattern2,
$query, $matches)
133 $replace =
"\\1 " . $prefix .
"_\\4\\5";
134 $matches[0] = preg_replace($pattern, $replace,
$query);
static prefixQuery($query, $prefix)
static splitMySqlFile(&$ret, $sql)