本文整理汇总了PHP中PMA_SQP_isError函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_SQP_isError函数的具体用法?PHP PMA_SQP_isError怎么用?PHP PMA_SQP_isError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_SQP_isError函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PMA_mysqlDie
/**
* Displays a MySQL error message in the right frame.
*
* @param string the error message
* @param string the sql query that failed
* @param boolean whether to show a "modify" link or not
* @param string the "back" link url (full path is not required)
* @param boolean EXIT the page?
*
* @global array the configuration array
*
* @access public
*/
function PMA_mysqlDie($error_message = '', $the_query = '', $is_modify_link = TRUE, $back_url = '', $exit = TRUE)
{
global $cfg, $table, $db, $sql_query;
require_once './header.inc.php';
if (!$error_message) {
$error_message = PMA_DBI_getError();
}
if (!$the_query && !empty($GLOBALS['sql_query'])) {
$the_query = $GLOBALS['sql_query'];
}
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
// Revised, Robbat2 - 13 Janurary 2003, 2:59PM
if (!function_exists('PMA_SQP_isError') || PMA_SQP_isError()) {
$formatted_sql = htmlspecialchars($the_query);
} else {
$formatted_sql = PMA_formatSql(PMA_SQP_parse($the_query), $the_query);
}
// ---
echo "\n" . '<!-- PMA-SQL-ERROR -->' . "\n";
echo ' <table border="0" cellpadding="2" cellspacing="1">' . ' <tr>' . "\n" . ' <th class="tblHeadError"><div class="errorhead">' . $GLOBALS['strError'] . '</div></th>' . "\n" . ' </tr>' . "\n" . ' <tr>' . "\n" . ' <td>';
// if the config password is wrong, or the MySQL server does not
// respond, do not show the query that would reveal the
// username/password
if (!empty($the_query) && !strstr($the_query, 'connect')) {
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
// Revised, Robbat2 - 13 Janurary 2003, 2:59PM
if (function_exists('PMA_SQP_isError') && PMA_SQP_isError()) {
echo PMA_SQP_getErrorString();
}
// ---
// modified to show me the help on sql errors (Michael Keck)
echo '<div class="tblWarn"><p>' . "\n";
echo ' <b>' . $GLOBALS['strSQLQuery'] . ':</b>' . "\n";
if (strstr(strtolower($formatted_sql), 'select')) {
// please show me help to the error on select
echo PMA_showMySQLDocu('Reference', 'SELECT');
}
if ($is_modify_link && isset($db)) {
if (isset($table)) {
$doedit_goto = '<a href="tbl_properties.php?' . PMA_generate_common_url($db, $table) . '&sql_query=' . urlencode($the_query) . '&show_query=1">';
} else {
$doedit_goto = '<a href="db_details.php?' . PMA_generate_common_url($db) . '&sql_query=' . urlencode($the_query) . '&show_query=1">';
}
if ($GLOBALS['cfg']['PropertiesIconic']) {
echo $doedit_goto . '<img src=" ' . $GLOBALS['pmaThemeImage'] . 'b_edit.png" width="16" height="16" border="0" hspace="2" align="middle" alt="' . $GLOBALS['strEdit'] . '" />' . '</a>';
} else {
echo ' [' . $doedit_goto . $GLOBALS['strEdit'] . '</a>' . ']' . "\n";
}
}
// end if
echo '</p>' . "\n" . '<p>' . "\n" . ' ' . $formatted_sql . "\n" . '</p></div>' . "\n";
}
// end if
$tmp_mysql_error = '';
// for saving the original $error_message
if (!empty($error_message)) {
$tmp_mysql_error = strtolower($error_message);
// save the original $error_message
$error_message = htmlspecialchars($error_message);
$error_message = preg_replace("@((\r\n)|(\r)|(\n)){3,}@", "\n\n", $error_message);
}
// modified to show me the help on error-returns (Michael Keck)
echo '<div class="tblWarn"><p>' . "\n" . ' <b>' . $GLOBALS['strMySQLSaid'] . '</b>' . PMA_showMySQLDocu('Error-returns', 'Error-returns') . "\n" . '</p>' . "\n";
// The error message will be displayed within a CODE segment.
// To preserve original formatting, but allow wordwrapping, we do a couple of replacements
// Replace all non-single blanks with their HTML-counterpart
$error_message = str_replace(' ', ' ', $error_message);
// Replace TAB-characters with their HTML-counterpart
$error_message = str_replace("\t", ' ', $error_message);
// Replace linebreaks
$error_message = nl2br($error_message);
echo '<code>' . "\n" . $error_message . "\n" . '</code><br />' . "\n";
// feature request #1036254:
// Add a link by MySQL-Error #1062 - Duplicate entry
// 2004-10-20 by mk.keck
if (substr($error_message, 1, 4) == '1062') {
// TODO: do not assume that the error message is in English
// and do not use mysql_result()
// explode the entry and the column
$arr_mysql_val_key = explode('entry \'', $tmp_mysql_error);
$arr_mysql_val_key = explode('\' for key', $arr_mysql_val_key[1]);
// get the duplicate value
$string_duplicate_val = trim(strtolower($arr_mysql_val_key[0]));
// get the field name ...
$string_duplicate_key = mysql_result(mysql_query("SHOW FIELDS FROM " . $table), $arr_mysql_val_key[1] - 1, 0);
//.........这里部分代码省略.........
示例2: PMA_SQP_formatHtml
/**
* Formats SQL queries to html
*
* @param array The SQL queries
* @param string mode
* @param integer starting token
* @param integer number of tokens to format, -1 = all
*
* @return string The formatted SQL queries
*
* @access public
*/
function PMA_SQP_formatHtml($arr, $mode = 'color', $start_token = 0, $number_of_tokens = -1)
{
// then check for an array
if (!is_array($arr)) {
return htmlspecialchars($arr);
}
// first check for the SQL parser having hit an error
if (PMA_SQP_isError()) {
return htmlspecialchars($arr['raw']);
}
// else do it properly
switch ($mode) {
case 'color':
$str = '<span class="syntax">';
$html_line_break = '<br />';
break;
case 'query_only':
$str = '';
$html_line_break = "\n";
break;
case 'text':
$str = '';
$html_line_break = '<br />';
break;
}
// end switch
$indent = 0;
$bracketlevel = 0;
$functionlevel = 0;
$infunction = FALSE;
$space_punct_listsep = ' ';
$space_punct_listsep_function_name = ' ';
// $space_alpha_reserved_word = '<br />'."\n";
$space_alpha_reserved_word = ' ';
$keywords_with_brackets_1before = array('INDEX', 'KEY', 'ON', 'USING');
$keywords_with_brackets_1before_cnt = 4;
$keywords_with_brackets_2before = array('IGNORE', 'INDEX', 'INTO', 'KEY', 'PRIMARY', 'PROCEDURE', 'REFERENCES', 'UNIQUE', 'USE');
// $keywords_with_brackets_2before_cnt = count($keywords_with_brackets_2before);
$keywords_with_brackets_2before_cnt = 9;
// These reserved words do NOT get a newline placed near them.
$keywords_no_newline = array('AS', 'ASC', 'DESC', 'DISTINCT', 'HOUR', 'INTERVAL', 'IS', 'LIKE', 'NOT', 'NULL', 'ON', 'REGEXP');
$keywords_no_newline_cnt = 12;
// These reserved words introduce a privilege list
$keywords_priv_list = array('GRANT', 'REVOKE');
$keywords_priv_list_cnt = 2;
if ($number_of_tokens == -1) {
$arraysize = $arr['len'];
} else {
$arraysize = $number_of_tokens;
}
$typearr = array();
if ($arraysize >= 0) {
$typearr[0] = '';
$typearr[1] = '';
$typearr[2] = '';
//$typearr[3] = $arr[0]['type'];
$typearr[3] = $arr[$start_token]['type'];
}
$in_priv_list = FALSE;
for ($i = $start_token; $i < $arraysize; $i++) {
// DEBUG echo "<b>" . $arr[$i]['data'] . "</b> " . $arr[$i]['type'] . "<br />";
$before = '';
$after = '';
$indent = 0;
// array_shift($typearr);
/*
0 prev2
1 prev
2 current
3 next
*/
if ($i + 1 < $arraysize) {
// array_push($typearr, $arr[$i + 1]['type']);
$typearr[4] = $arr[$i + 1]['type'];
} else {
//array_push($typearr, NULL);
$typearr[4] = '';
}
for ($j = 0; $j < 4; $j++) {
$typearr[$j] = $typearr[$j + 1];
}
switch ($typearr[2]) {
case 'white_newline':
$before = '';
break;
case 'punct_bracket_open_round':
$bracketlevel++;
$infunction = FALSE;
//.........这里部分代码省略.........
示例3: PMA_showMessage
//.........这里部分代码省略.........
echo PMA_sanitize($message);
if (isset($GLOBALS['special_message'])) {
echo PMA_sanitize($GLOBALS['special_message']);
unset($GLOBALS['special_message']);
}
echo '</div>';
}
if ($cfg['ShowSQL'] == true && !empty($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));
$query_base = preg_replace('/((\\015\\012)|(\\015)|(\\012))/', $new_line, $query_base);
} else {
$query_base = $sql_query;
}
$query_too_big = false;
if (strlen($query_base) > $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(substr($sql_query, 0, $cfg['MaxCharactersInDisplayedSQL']) . '[...]'));
} elseif (!empty($GLOBALS['parsed_sql']) && $query_base == $GLOBALS['parsed_sql']['raw']) {
// (here, use "! empty" because when deleting a bookmark,
// $GLOBALS['parsed_sql'] is set but empty
$parsed_sql = $GLOBALS['parsed_sql'];
} else {
// Parse SQL if needed
$parsed_sql = PMA_SQP_parse($query_base);
}
// Analyze it
if (isset($parsed_sql) && !PMA_SQP_isError()) {
$analyzed_display_query = PMA_SQP_analyze($parsed_sql);
// Same as below (append LIMIT), append the remembered ORDER BY
if ($GLOBALS['cfg']['RememberSorting'] && isset($analyzed_display_query[0]['queryflags']['select_from']) && isset($GLOBALS['sql_order_to_append'])) {
$query_base = $analyzed_display_query[0]['section_before_limit'] . "\n" . $GLOBALS['sql_order_to_append'] . $analyzed_display_query[0]['limit_clause'] . ' ' . $analyzed_display_query[0]['section_after_limit'];
// Need to reparse query
$parsed_sql = PMA_SQP_parse($query_base);
// update the $analyzed_display_query
$analyzed_display_query[0]['section_before_limit'] .= $GLOBALS['sql_order_to_append'];
$analyzed_display_query[0]['order_by_clause'] = $GLOBALS['sorted_col'];
}
// Here we append the LIMIT added for navigation, to
// enable its display. Adding it higher in the code
// to $sql_query would create a problem when
// using the Refresh or Edit links.
// Only append it on SELECTs.
/**
* @todo what would be the best to do when someone hits Refresh:
* use the current LIMITs ?
*/
if (isset($analyzed_display_query[0]['queryflags']['select_from']) && isset($GLOBALS['sql_limit_to_append'])) {
$query_base = $analyzed_display_query[0]['section_before_limit'] . "\n" . $GLOBALS['sql_limit_to_append'] . $analyzed_display_query[0]['section_after_limit'];
// Need to reparse query
$parsed_sql = PMA_SQP_parse($query_base);
}
}
if (!empty($GLOBALS['show_as_php'])) {
$query_base = '$sql = "' . $query_base;
} elseif (!empty($GLOBALS['validatequery'])) {
try {
$query_base = PMA_validateSQL($query_base);
} catch (Exception $e) {
PMA_Message::error(__('Failed to connect to SQL validator!'))->display();
示例4: PMA_SQP_format
/**
* Formats SQL queries
*
* @param array $arr The SQL queries
* @param string $mode formatting mode
* @param integer $start_token starting token
* @param integer $number_of_tokens number of tokens to format, -1 = all
*
* @return string The formatted SQL queries
*
* @access public
*/
function PMA_SQP_format($arr, $mode = 'text', $start_token = 0, $number_of_tokens = -1)
{
//DEBUG echo 'in Format<pre>'; print_r($arr); echo '</pre>';
// then check for an array
if (!is_array($arr)) {
return htmlspecialchars($arr);
}
// first check for the SQL parser having hit an error
if (PMA_SQP_isError()) {
return htmlspecialchars($arr['raw']);
}
// else do it properly
switch ($mode) {
case 'query_only':
$str = '';
$html_line_break = "\n";
break;
case 'text':
$str = '';
$html_line_break = '<br />';
break;
}
// end switch
$indent = 0;
$bracketlevel = 0;
$functionlevel = 0;
$infunction = false;
$space_punct_listsep = ' ';
$space_punct_listsep_function_name = ' ';
// $space_alpha_reserved_word = '<br />'."\n";
$space_alpha_reserved_word = ' ';
$keywords_with_brackets_1before = array('INDEX' => 1, 'KEY' => 1, 'ON' => 1, 'USING' => 1);
$keywords_with_brackets_2before = array('IGNORE' => 1, 'INDEX' => 1, 'INTO' => 1, 'KEY' => 1, 'PRIMARY' => 1, 'PROCEDURE' => 1, 'REFERENCES' => 1, 'UNIQUE' => 1, 'USE' => 1);
// These reserved words do NOT get a newline placed near them.
$keywords_no_newline = array('AS' => 1, 'ASC' => 1, 'DESC' => 1, 'DISTINCT' => 1, 'DUPLICATE' => 1, 'HOUR' => 1, 'INTERVAL' => 1, 'IS' => 1, 'LIKE' => 1, 'NOT' => 1, 'NULL' => 1, 'ON' => 1, 'REGEXP' => 1);
// These reserved words introduce a privilege list
$keywords_priv_list = array('GRANT' => 1, 'REVOKE' => 1);
if ($number_of_tokens == -1) {
$number_of_tokens = $arr['len'];
}
$typearr = array();
if ($number_of_tokens >= 0) {
$typearr[0] = '';
$typearr[1] = '';
$typearr[2] = '';
$typearr[3] = $arr[$start_token]['type'];
}
$in_priv_list = false;
for ($i = $start_token; $i < $number_of_tokens; $i++) {
// DEBUG echo "Loop format <strong>" . $arr[$i]['data']
// . "</strong> " . $arr[$i]['type'] . "<br />";
$before = '';
$after = '';
// array_shift($typearr);
/*
0 prev2
1 prev
2 current
3 next
*/
if ($i + 1 < $number_of_tokens) {
$typearr[4] = $arr[$i + 1]['type'];
} else {
$typearr[4] = '';
}
for ($j = 0; $j < 4; $j++) {
$typearr[$j] = $typearr[$j + 1];
}
switch ($typearr[2]) {
case 'alpha_bitfield_constant_introducer':
$before = ' ';
$after = '';
break;
case 'white_newline':
$before = '';
break;
case 'punct_bracket_open_round':
$bracketlevel++;
$infunction = false;
$keyword_brackets_2before = isset($keywords_with_brackets_2before[strtoupper($arr[$i - 2]['data'])]);
$keyword_brackets_1before = isset($keywords_with_brackets_1before[strtoupper($arr[$i - 1]['data'])]);
// Make sure this array is sorted!
if ($typearr[1] == 'alpha_functionName' || $typearr[1] == 'alpha_columnType' || $typearr[1] == 'punct' || $typearr[3] == 'digit_integer' || $typearr[3] == 'digit_hex' || $typearr[3] == 'digit_float' || $typearr[0] == 'alpha_reservedWord' && $keyword_brackets_2before || $typearr[1] == 'alpha_reservedWord' && $keyword_brackets_1before) {
$functionlevel++;
$infunction = true;
$after .= ' ';
} else {
$indent++;
//.........这里部分代码省略.........
示例5: PMA_SQP_format
/**
* Formats SQL queries
*
* @param array $arr The SQL queries
* @param string $mode formatting mode
* @param integer $start_token starting token
* @param integer $number_of_tokens number of tokens to format, -1 = all
*
* @return string The formatted SQL queries
*
* @access public
*/
function PMA_SQP_format($arr, $mode = 'text', $start_token = 0, $number_of_tokens = -1)
{
//DEBUG echo 'in Format<pre>'; print_r($arr); echo '</pre>';
// then check for an array
if (!is_array($arr)) {
return htmlspecialchars($arr);
}
// first check for the SQL parser having hit an error
if (PMA_SQP_isError()) {
return htmlspecialchars($arr['raw']);
}
// else do it properly
switch ($mode) {
case 'query_only':
$str = '';
$html_line_break = "\n";
break;
case 'text':
$str = '';
$html_line_break = '<br />';
break;
}
// end switch
$indent = 0;
$bracketlevel = 0;
$functionlevel = 0;
$infunction = false;
$space_punct_listsep = ' ';
$space_punct_listsep_function_name = ' ';
// $space_alpha_reserved_word = '<br />'."\n";
$space_alpha_reserved_word = ' ';
$keywords_with_brackets_1before = array('INDEX' => 1, 'KEY' => 1, 'ON' => 1, 'USING' => 1);
$keywords_with_brackets_2before = array('IGNORE' => 1, 'INDEX' => 1, 'INTO' => 1, 'KEY' => 1, 'PRIMARY' => 1, 'PROCEDURE' => 1, 'REFERENCES' => 1, 'UNIQUE' => 1, 'USE' => 1);
// These reserved words do NOT get a newline placed near them.
$keywords_no_newline = array('AS' => 1, 'ASC' => 1, 'DESC' => 1, 'DISTINCT' => 1, 'DUPLICATE' => 1, 'HOUR' => 1, 'INTERVAL' => 1, 'IS' => 1, 'LIKE' => 1, 'NOT' => 1, 'NULL' => 1, 'ON' => 1, 'REGEXP' => 1);
// These reserved words introduce a privilege list
$keywords_priv_list = array('GRANT' => 1, 'REVOKE' => 1);
if ($number_of_tokens == -1) {
$number_of_tokens = $arr['len'];
}
$typearr = array();
if ($number_of_tokens >= 0) {
$typearr[0] = '';
$typearr[1] = '';
$typearr[2] = '';
$typearr[3] = $arr[$start_token]['type'];
}
$in_priv_list = false;
for ($i = $start_token; $i < $number_of_tokens; $i++) {
// DEBUG echo "Loop format <strong>" . $arr[$i]['data']
// . "</strong> " . $arr[$i]['type'] . "<br />";
$before = '';
$after = '';
// array_shift($typearr);
/*
0 prev2
1 prev
2 current
3 next
*/
if ($i + 1 < $number_of_tokens) {
$typearr[4] = $arr[$i + 1]['type'];
} else {
$typearr[4] = '';
}
for ($j = 0; $j < 4; $j++) {
$typearr[$j] = $typearr[$j + 1];
}
switch ($typearr[2]) {
case 'alpha_bitfield_constant_introducer':
$before = ' ';
$after = '';
break;
case 'white_newline':
$before = '';
break;
case 'punct_bracket_open_round':
$bracketlevel++;
$infunction = false;
$keyword_brackets_2before = isset($keywords_with_brackets_2before[mb_strtoupper($arr[$i - 2]['data'])]);
$keyword_brackets_1before = isset($keywords_with_brackets_1before[mb_strtoupper($arr[$i - 1]['data'])]);
// Make sure this array is sorted!
if ($typearr[1] == 'alpha_functionName' || $typearr[1] == 'alpha_columnType' || $typearr[1] == 'punct' || $typearr[3] == 'digit_integer' || $typearr[3] == 'digit_hex' || $typearr[3] == 'digit_float' || $typearr[0] == 'alpha_reservedWord' && $keyword_brackets_2before || $typearr[1] == 'alpha_reservedWord' && $keyword_brackets_1before) {
$functionlevel++;
$infunction = true;
$after .= ' ';
} else {
$indent++;
//.........这里部分代码省略.........
示例6: PMA_mysqlDie
/**
* Displays a MySQL error message in the right frame.
*
* @uses footer.inc.php
* @uses header.inc.php
* @uses $GLOBALS['sql_query']
* @uses $GLOBALS['strError']
* @uses $GLOBALS['strSQLQuery']
* @uses $GLOBALS['pmaThemeImage']
* @uses $GLOBALS['strEdit']
* @uses $GLOBALS['strMySQLSaid']
* @uses $GLOBALS['cfg']['PropertiesIconic']
* @uses $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']
* @uses PMA_backquote()
* @uses PMA_DBI_getError()
* @uses PMA_formatSql()
* @uses PMA_generate_common_hidden_inputs()
* @uses PMA_generate_common_url()
* @uses PMA_showMySQLDocu()
* @uses PMA_sqlAddslashes()
* @uses PMA_SQP_isError()
* @uses PMA_SQP_parse()
* @uses PMA_SQP_getErrorString()
* @uses strtolower()
* @uses urlencode()
* @uses str_replace()
* @uses nl2br()
* @uses substr()
* @uses preg_replace()
* @uses preg_match()
* @uses explode()
* @uses implode()
* @uses is_array()
* @uses function_exists()
* @uses htmlspecialchars()
* @uses trim()
* @uses strstr()
* @param string the error message
* @param string the sql query that failed
* @param boolean whether to show a "modify" link or not
* @param string the "back" link url (full path is not required)
* @param boolean EXIT the page?
*
* @global string the curent table
* @global string the current db
*
* @access public
*/
function PMA_mysqlDie($error_message = '', $the_query = '', $is_modify_link = true, $back_url = '', $exit = true)
{
global $table, $db;
/**
* start http output, display html headers
*/
require_once './libraries/header.inc.php';
$error_msg_output = '';
if (!$error_message) {
$error_message = PMA_DBI_getError();
}
if (!$the_query && !empty($GLOBALS['sql_query'])) {
$the_query = $GLOBALS['sql_query'];
}
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
// Revised, Robbat2 - 13 January 2003, 2:59PM
if (!function_exists('PMA_SQP_isError') || PMA_SQP_isError()) {
$formatted_sql = htmlspecialchars($the_query);
} elseif (empty($the_query) || trim($the_query) == '') {
$formatted_sql = '';
} else {
if (strlen($the_query) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
$formatted_sql = substr($the_query, 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) . '[...]';
} else {
$formatted_sql = PMA_formatSql(PMA_SQP_parse($the_query), $the_query);
}
}
// ---
$error_msg_output .= "\n" . '<!-- PMA-SQL-ERROR -->' . "\n";
$error_msg_output .= ' <div class="error"><h1>' . $GLOBALS['strError'] . '</h1>' . "\n";
// if the config password is wrong, or the MySQL server does not
// respond, do not show the query that would reveal the
// username/password
if (!empty($the_query) && !strstr($the_query, 'connect')) {
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
// Revised, Robbat2 - 13 January 2003, 2:59PM
if (function_exists('PMA_SQP_isError') && PMA_SQP_isError()) {
$error_msg_output .= PMA_SQP_getErrorString() . "\n";
$error_msg_output .= '<br />' . "\n";
}
// ---
// modified to show me the help on sql errors (Michael Keck)
$error_msg_output .= ' <p><strong>' . $GLOBALS['strSQLQuery'] . ':</strong>' . "\n";
if (strstr(strtolower($formatted_sql), 'select')) {
// please show me help to the error on select
$error_msg_output .= PMA_showMySQLDocu('SQL-Syntax', 'SELECT');
}
if ($is_modify_link) {
$_url_params = array('sql_query' => $the_query, 'show_query' => 1);
if (strlen($table)) {
//.........这里部分代码省略.........
示例7: getMessage
/**
* Prepare the message and the query
* usually the message is the result of the query executed
*
* @param string $message the message to display
* @param string $sql_query the query to display
* @param string $type the type (level) of the message
* @param boolean $is_view is this a message after a VIEW operation?
*
* @return string
*
* @access public
*/
public static function getMessage($message, $sql_query = null, $type = 'notice', $is_view = false)
{
global $cfg;
$retval = '';
if (null === $sql_query) {
if (!empty($GLOBALS['display_query'])) {
$sql_query = $GLOBALS['display_query'];
} elseif (!empty($GLOBALS['unparsed_sql'])) {
$sql_query = $GLOBALS['unparsed_sql'];
} elseif (!empty($GLOBALS['sql_query'])) {
$sql_query = $GLOBALS['sql_query'];
} else {
$sql_query = '';
}
}
if (isset($GLOBALS['using_bookmark_message'])) {
$retval .= $GLOBALS['using_bookmark_message']->getDisplay();
unset($GLOBALS['using_bookmark_message']);
}
// In an Ajax request, $GLOBALS['cell_align_left'] may not be defined. Hence,
// check for it's presence before using it
$retval .= '<div id="result_query"' . (isset($GLOBALS['cell_align_left']) ? ' style="text-align: ' . $GLOBALS['cell_align_left'] . '"' : '') . '>' . "\n";
if ($message instanceof PMA_Message) {
if (isset($GLOBALS['special_message'])) {
$message->addMessage($GLOBALS['special_message']);
unset($GLOBALS['special_message']);
}
$retval .= $message->getDisplay();
} else {
$retval .= '<div class="' . $type . '">';
$retval .= PMA_sanitize($message);
if (isset($GLOBALS['special_message'])) {
$retval .= PMA_sanitize($GLOBALS['special_message']);
unset($GLOBALS['special_message']);
}
$retval .= '</div>';
}
if ($cfg['ShowSQL'] == true && !empty($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));
$query_base = preg_replace('/((\\015\\012)|(\\015)|(\\012))/', $new_line, $query_base);
} else {
$query_base = $sql_query;
}
$query_too_big = false;
if (strlen($query_base) > $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(substr($sql_query, 0, $cfg['MaxCharactersInDisplayedSQL']) . '[...]'));
} elseif (!empty($GLOBALS['parsed_sql']) && $query_base == $GLOBALS['parsed_sql']['raw']) {
// (here, use "! empty" because when deleting a bookmark,
// $GLOBALS['parsed_sql'] is set but empty
$parsed_sql = $GLOBALS['parsed_sql'];
} else {
// Parse SQL if needed
$parsed_sql = PMA_SQP_parse($query_base);
}
// Analyze it
if (isset($parsed_sql) && !PMA_SQP_isError()) {
$analyzed_display_query = PMA_SQP_analyze($parsed_sql);
// Same as below (append LIMIT), append the remembered ORDER BY
if ($GLOBALS['cfg']['RememberSorting'] && isset($analyzed_display_query[0]['queryflags']['select_from']) && isset($GLOBALS['sql_order_to_append'])) {
$query_base = $analyzed_display_query[0]['section_before_limit'] . "\n" . $GLOBALS['sql_order_to_append'] . $analyzed_display_query[0]['limit_clause'] . ' ' . $analyzed_display_query[0]['section_after_limit'];
// Need to reparse query
$parsed_sql = PMA_SQP_parse($query_base);
// update the $analyzed_display_query
$analyzed_display_query[0]['section_before_limit'] .= $GLOBALS['sql_order_to_append'];
$analyzed_display_query[0]['order_by_clause'] = $GLOBALS['sorted_col'];
}
// Here we append the LIMIT added for navigation, to
// enable its display. Adding it higher in the code
// to $sql_query would create a problem when
// using the Refresh or Edit links.
// Only append it on SELECTs.
/**
* @todo what would be the best to do when someone hits Refresh:
* use the current LIMITs ?
*/
if (isset($analyzed_display_query[0]['queryflags']['select_from']) && !empty($GLOBALS['sql_limit_to_append'])) {
$query_base = $analyzed_display_query[0]['section_before_limit'] . "\n" . $GLOBALS['sql_limit_to_append'] . $analyzed_display_query[0]['section_after_limit'];
// Need to reparse query
$parsed_sql = PMA_SQP_parse($query_base);
//.........这里部分代码省略.........
示例8: PMA_mysqlDie
/**
* Displays a MySQL error message in the right frame.
*
* @param string the error message
* @param string the sql query that failed
* @param boolean whether to show a "modify" link or not
* @param string the "back" link url (full path is not required)
* @param boolean EXIT the page?
*
* @global array the configuration array
*
* @access public
*/
function PMA_mysqlDie($error_message = '', $the_query = '', $is_modify_link = true, $back_url = '', $exit = true)
{
global $cfg, $table, $db, $sql_query;
require_once './libraries/header.inc.php';
if (!$error_message) {
$error_message = PMA_DBI_getError();
}
if (!$the_query && !empty($GLOBALS['sql_query'])) {
$the_query = $GLOBALS['sql_query'];
}
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
// Revised, Robbat2 - 13 January 2003, 2:59PM
if (!function_exists('PMA_SQP_isError') || PMA_SQP_isError()) {
$formatted_sql = htmlspecialchars($the_query);
} elseif (empty($the_query) || trim($the_query) == '') {
$formatted_sql = '';
} else {
$formatted_sql = PMA_formatSql(PMA_SQP_parse($the_query), $the_query);
}
// ---
echo "\n" . '<!-- PMA-SQL-ERROR -->' . "\n";
echo ' <div class="error"><h1>' . $GLOBALS['strError'] . '</h1>' . "\n";
// if the config password is wrong, or the MySQL server does not
// respond, do not show the query that would reveal the
// username/password
if (!empty($the_query) && !strstr($the_query, 'connect')) {
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
// Revised, Robbat2 - 13 January 2003, 2:59PM
if (function_exists('PMA_SQP_isError') && PMA_SQP_isError()) {
echo PMA_SQP_getErrorString() . "\n";
echo '<br />' . "\n";
}
// ---
// modified to show me the help on sql errors (Michael Keck)
echo ' <p><strong>' . $GLOBALS['strSQLQuery'] . ':</strong>' . "\n";
if (strstr(strtolower($formatted_sql), 'select')) {
// please show me help to the error on select
echo PMA_showMySQLDocu('SQL-Syntax', 'SELECT');
}
if ($is_modify_link && isset($db)) {
if (isset($table)) {
$doedit_goto = '<a href="tbl_properties.php?' . PMA_generate_common_url($db, $table) . '&sql_query=' . urlencode($the_query) . '&show_query=1">';
} else {
$doedit_goto = '<a href="db_details.php?' . PMA_generate_common_url($db) . '&sql_query=' . urlencode($the_query) . '&show_query=1">';
}
if ($GLOBALS['cfg']['PropertiesIconic']) {
echo $doedit_goto . '<img class="icon" src=" ' . $GLOBALS['pmaThemeImage'] . 'b_edit.png" width="16" height="16" alt="' . $GLOBALS['strEdit'] . '" />' . '</a>';
} else {
echo ' [' . $doedit_goto . $GLOBALS['strEdit'] . '</a>' . ']' . "\n";
}
}
// end if
echo ' </p>' . "\n" . ' <p>' . "\n" . ' ' . $formatted_sql . "\n" . ' </p>' . "\n";
}
// end if
$tmp_mysql_error = '';
// for saving the original $error_message
if (!empty($error_message)) {
$tmp_mysql_error = strtolower($error_message);
// save the original $error_message
$error_message = htmlspecialchars($error_message);
$error_message = preg_replace("@((\r\n)|(\r)|(\n)){3,}@", "\n\n", $error_message);
}
// modified to show me the help on error-returns (Michael Keck)
// (now error-messages-server)
echo '<p>' . "\n" . ' <strong>' . $GLOBALS['strMySQLSaid'] . '</strong>' . PMA_showMySQLDocu('Error-messages-server', 'Error-messages-server') . "\n" . '</p>' . "\n";
// The error message will be displayed within a CODE segment.
// To preserve original formatting, but allow wordwrapping, we do a couple of replacements
// Replace all non-single blanks with their HTML-counterpart
$error_message = str_replace(' ', ' ', $error_message);
// Replace TAB-characters with their HTML-counterpart
$error_message = str_replace("\t", ' ', $error_message);
// Replace linebreaks
$error_message = nl2br($error_message);
echo '<code>' . "\n" . $error_message . "\n" . '</code><br />' . "\n";
// feature request #1036254:
// Add a link by MySQL-Error #1062 - Duplicate entry
// 2004-10-20 by mkkeck
// 2005-01-17 modified by mkkeck bugfix
if (substr($error_message, 1, 4) == '1062') {
// get the duplicate entry
// get table name
// TODO: what would be the best delimiter, while avoiding
// special characters that can become high-ascii after editing,
// depending upon which editor is used by the developer?
//.........这里部分代码省略.........
示例9: PMA_mysqlDie
/**
* Displays a MySQL error message in the right frame.
*
* @param string the error mesage
* @param string the sql query that failed
* @param boolean whether to show a "modify" link or not
* @param string the "back" link url (full path is not required)
* @param boolean EXIT the page?
*
* @global array the configuration array
*
* @access public
*/
function PMA_mysqlDie($error_message = '', $the_query = '', $is_modify_link = TRUE, $back_url = '', $exit = TRUE)
{
global $cfg, $table, $db, $sql_query;
require_once './header.inc.php';
if (!$error_message) {
$error_message = PMA_mysql_error();
}
if (!$the_query && !empty($GLOBALS['sql_query'])) {
$the_query = $GLOBALS['sql_query'];
}
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
// Revised, Robbat2 - 13 Janurary 2003, 2:59PM
if (!function_exists('PMA_SQP_isError') || PMA_SQP_isError()) {
$formatted_sql = htmlspecialchars($the_query);
} else {
$formatted_sql = PMA_formatSql(PMA_SQP_parse($the_query), $the_query);
}
// ---
echo '<p><b>' . $GLOBALS['strError'] . '</b></p>' . "\n";
// if the config password is wrong, or the MySQL server does not
// respond, do not show the query that would reveal the
// username/password
if (!empty($the_query) && !strstr($the_query, 'connect')) {
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
// Revised, Robbat2 - 13 Janurary 2003, 2:59PM
if (function_exists('PMA_SQP_isError') && PMA_SQP_isError()) {
echo PMA_SQP_getErrorString();
}
// ---
echo '<p>' . "\n";
echo ' ' . $GLOBALS['strSQLQuery'] . ' : ' . "\n";
if ($is_modify_link && isset($db)) {
echo ' [' . '<a href="db_details.php?' . PMA_generate_common_url($GLOBALS['db']) . '&sql_query=' . urlencode($the_query) . '&show_query=1">' . $GLOBALS['strEdit'] . '</a>' . ']' . "\n";
}
// end if
echo '</p>' . "\n" . '<p>' . "\n" . ' ' . $formatted_sql . "\n" . '</p>' . "\n";
}
// end if
if (!empty($error_message)) {
$error_message = htmlspecialchars($error_message);
$error_message = preg_replace("@((\r\n)|(\r)|(\n)){3,}@", "\n\n", $error_message);
}
echo '<p>' . "\n" . ' ' . $GLOBALS['strMySQLSaid'] . '<br />' . "\n" . '</p>' . "\n";
// The error message will be displayed within a CODE segment.
// To preserve original formatting, but allow wordwrapping, we do a couple of replacements
// Replace all non-single blanks with their HTML-counterpart
$error_message = str_replace(' ', ' ', $error_message);
// Replace TAB-characters with their HTML-counterpart
$error_message = str_replace("\t", ' ', $error_message);
// Replace linebreaks
$error_message = nl2br($error_message);
echo '<code>' . "\n" . $error_message . "\n" . '</code><br /><br />' . "\n";
echo PMA_showMySQLDocu('Error-returns', 'Error-returns');
if (!empty($back_url) && $exit) {
echo ' · [<a href="' . (strstr($back_url, '?') ? $back_url . '&no_history=true' : $back_url . '?no_history=true') . '">' . $GLOBALS['strBack'] . '</a>]';
}
echo "\n";
if ($exit) {
require_once './footer.inc.php';
}
}
示例10: PMA_mysqlDie
/**
* Displays a MySQL error message in the right frame.
*
* @param string the error mesage
* @param string the sql query that failed
* @param boolean whether to show a "modify" link or not
* @param string the "back" link url (full path is not required)
* @param boolean EXIT the page?
*
* @global array the configuration array
*
* @access public
*/
function PMA_mysqlDie($error_message = '', $the_query = '', $is_modify_link = TRUE, $back_url = '', $exit = TRUE)
{
global $cfg, $table, $db, $sql_query;
require_once './header.inc.php';
if (!$error_message) {
$error_message = PMA_DBI_getError();
}
if (!$the_query && !empty($GLOBALS['sql_query'])) {
$the_query = $GLOBALS['sql_query'];
}
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
// Revised, Robbat2 - 13 Janurary 2003, 2:59PM
if (!function_exists('PMA_SQP_isError') || PMA_SQP_isError()) {
$formatted_sql = htmlspecialchars($the_query);
} else {
$formatted_sql = PMA_formatSql(PMA_SQP_parse($the_query), $the_query);
}
// ---
echo "\n" . '<!-- PMA-SQL-ERROR -->' . "\n";
echo ' <table border="0" cellpadding="2" cellspacing="1">' . ' <tr>' . "\n" . ' <th class="tblHeadError"><div class="errorhead">' . $GLOBALS['strError'] . '</div></th>' . "\n" . ' </tr>' . "\n" . ' <tr>' . "\n" . ' <td>';
// if the config password is wrong, or the MySQL server does not
// respond, do not show the query that would reveal the
// username/password
if (!empty($the_query) && !strstr($the_query, 'connect')) {
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
// Revised, Robbat2 - 13 Janurary 2003, 2:59PM
if (function_exists('PMA_SQP_isError') && PMA_SQP_isError()) {
echo PMA_SQP_getErrorString();
}
// ---
// modified to show me the help on sql errors (Michael Keck)
echo '<div class="tblWarn"><p>' . "\n";
echo ' <b>' . $GLOBALS['strSQLQuery'] . ':</b>' . "\n";
if (strstr(strtolower($formatted_sql), 'select')) {
// please show me help to the error on select
echo PMA_showMySQLDocu('Reference', 'SELECT');
}
if ($is_modify_link && isset($db)) {
if (isset($table)) {
$doedit_goto = '<a href="tbl_properties.php?' . PMA_generate_common_url($db, $table) . '&sql_query=' . urlencode($the_query) . '&show_query=1">';
} else {
$doedit_goto = '<a href="db_details.php?' . PMA_generate_common_url($db) . '&sql_query=' . urlencode($the_query) . '&show_query=1">';
}
if ($GLOBALS['cfg']['PropertiesIconic']) {
echo $doedit_goto . '<img src=" ' . $GLOBALS['pmaThemeImage'] . 'b_edit.png" width="16" height="16" border="0" hspace="2" align="absmiddle" alt="' . $GLOBALS['strEdit'] . '" />' . '</a>';
} else {
echo ' [' . $doedit_goto . $GLOBALS['strEdit'] . '</a>' . ']' . "\n";
}
}
// end if
echo '</p>' . "\n" . '<p>' . "\n" . ' ' . $formatted_sql . "\n" . '</p></div>' . "\n";
}
// end if
if (!empty($error_message)) {
$error_message = htmlspecialchars($error_message);
$error_message = preg_replace("@((\r\n)|(\r)|(\n)){3,}@", "\n\n", $error_message);
}
// modified to show me the help on error-returns (Michael Keck)
echo '<div class="tblWarn"><p>' . "\n" . ' <b>' . $GLOBALS['strMySQLSaid'] . '</b>' . PMA_showMySQLDocu('Error-returns', 'Error-returns') . "\n" . '</p>' . "\n";
// The error message will be displayed within a CODE segment.
// To preserve original formatting, but allow wordwrapping, we do a couple of replacements
// Replace all non-single blanks with their HTML-counterpart
$error_message = str_replace(' ', ' ', $error_message);
// Replace TAB-characters with their HTML-counterpart
$error_message = str_replace("\t", ' ', $error_message);
// Replace linebreaks
$error_message = nl2br($error_message);
echo '<code>' . "\n" . $error_message . "\n" . '</code><br /><br />' . "\n";
echo '</div>';
if (!empty($back_url) && $exit) {
$goto_back_url = '<a href="' . (strstr($back_url, '?') ? $back_url . '&no_history=true' : $back_url . '?no_history=true') . '"> ';
echo ' </td> ' . "\n" . ' </tr>' . "\n" . ' <tr><td class="tblHeaders" align="center">';
echo '[' . $goto_back_url . $GLOBALS['strBack'] . ' </a>]';
}
echo ' </td>' . "\n" . ' </tr>' . "\n" . ' </table>' . "\n\n";
if ($exit) {
require_once './footer.inc.php';
}
}