Simplify code for processing SQL query to display
Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
parent
84507dfeb6
commit
170c045507
@ -1130,44 +1130,38 @@ class Util
|
||||
}
|
||||
|
||||
if ($render_sql) {
|
||||
$query_too_big = false;
|
||||
|
||||
$queryLength = mb_strlen($sql_query);
|
||||
if ($queryLength > $cfg['MaxCharactersInDisplayedSQL']) {
|
||||
// when the query is large (for example an INSERT of binary
|
||||
// data), the parser chokes; so avoid parsing the query
|
||||
$query_too_big = true;
|
||||
$query_base = mb_substr(
|
||||
$sql_query,
|
||||
0,
|
||||
$cfg['MaxCharactersInDisplayedSQL']
|
||||
) . '[...]';
|
||||
} else {
|
||||
$query_base = $sql_query;
|
||||
}
|
||||
|
||||
// Html format the query to be displayed
|
||||
// If we want to show some sql code it is easiest to create it here
|
||||
/* SQL-Parser-Analyzer */
|
||||
|
||||
if (! empty($GLOBALS['show_as_php'])) {
|
||||
$new_line = '\\n"<br />' . "\n"
|
||||
. ' . "';
|
||||
$query_base = htmlspecialchars(addslashes($sql_query));
|
||||
$new_line = '\\n"<br />' . "\n" . ' . "';
|
||||
$query_base = htmlspecialchars(addslashes($query_base));
|
||||
$query_base = preg_replace(
|
||||
'/((\015\012)|(\015)|(\012))/',
|
||||
$new_line,
|
||||
$query_base
|
||||
);
|
||||
$query_base = '$sql = "' . $query_base . '"';
|
||||
} elseif ($query_too_big) {
|
||||
$query_base = htmlspecialchars($query_base);
|
||||
} else {
|
||||
$query_base = $sql_query;
|
||||
}
|
||||
|
||||
$query_too_big = false;
|
||||
|
||||
$queryLength = mb_strlen($query_base);
|
||||
if ($queryLength > $cfg['MaxCharactersInDisplayedSQL']) {
|
||||
// when the query is large (for example an INSERT of binary
|
||||
// data), the parser chokes; so avoid parsing the query
|
||||
$query_too_big = true;
|
||||
$shortened_query_base = nl2br(
|
||||
htmlspecialchars(
|
||||
mb_substr(
|
||||
$sql_query,
|
||||
0,
|
||||
$cfg['MaxCharactersInDisplayedSQL']
|
||||
) . '[...]'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (! empty($GLOBALS['show_as_php'])) {
|
||||
$query_base = '$sql = "' . $query_base;
|
||||
} elseif (isset($query_base)) {
|
||||
$query_base = self::formatSql($query_base);
|
||||
}
|
||||
|
||||
@ -1302,11 +1296,7 @@ class Util
|
||||
} //refresh
|
||||
|
||||
$retval .= '<div class="sqlOuter">';
|
||||
if ($query_too_big) {
|
||||
$retval .= $shortened_query_base;
|
||||
} else {
|
||||
$retval .= $query_base;
|
||||
}
|
||||
$retval .= $query_base;
|
||||
|
||||
//Clean up the end of the PHP
|
||||
if (! empty($GLOBALS['show_as_php'])) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user