本文整理汇总了PHP中PMA_unQuote函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_unQuote函数的具体用法?PHP PMA_unQuote怎么用?PHP PMA_unQuote使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_unQuote函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PMA_displayTable
/**
* Displays a table of results returned by a SQL query.
* This function is called by the "sql.php" script.
*
* @param integer the link id associated to the query which results have
* to be displayed
* @param array the display mode
* @param array the analyzed query
*
* @uses $_SESSION['tmp_user_values']['pos']
* @global string $db the database name
* @global string $table the table name
* @global string $goto the URL to go back in case of errors
* @global string $sql_query the current SQL query
* @global integer $num_rows the total number of rows returned by the
* SQL query
* @global integer $unlim_num_rows the total number of rows returned by the
* SQL query without any programmatically
* appended "LIMIT" clause
* @global array $fields_meta the list of fields properties
* @global integer $fields_cnt the total number of fields returned by
* the SQL query
* @global array $vertical_display informations used with vertical display
* mode
* @global array $highlight_columns column names to highlight
* @global array $cfgRelation the relation settings
*
* @access private
*
* @see PMA_showMessage(), PMA_setDisplayMode(),
* PMA_displayTableNavigation(), PMA_displayTableHeaders(),
* PMA_displayTableBody(), PMA_displayResultsOperations()
*/
function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
{
global $db, $table, $goto;
global $sql_query, $num_rows, $unlim_num_rows, $fields_meta, $fields_cnt;
global $vertical_display, $highlight_columns;
global $cfgRelation;
global $showtable;
// why was this called here? (already called from sql.php)
//PMA_displayTable_checkConfigParams();
/**
* @todo move this to a central place
* @todo for other future table types
*/
$is_innodb = isset($showtable['Type']) && $showtable['Type'] == 'InnoDB';
if ($is_innodb && !isset($analyzed_sql[0]['queryflags']['union']) && !isset($analyzed_sql[0]['table_ref'][1]['table_name']) && (empty($analyzed_sql[0]['where_clause']) || $analyzed_sql[0]['where_clause'] == '1 ')) {
// "j u s t b r o w s i n g"
$pre_count = '~';
$after_count = PMA_showHint(PMA_sanitize($GLOBALS['strApproximateCount']), true);
} else {
$pre_count = '';
$after_count = '';
}
// 1. ----- Prepares the work -----
// 1.1 Gets the informations about which functionalities should be
// displayed
$total = '';
$is_display = PMA_setDisplayMode($the_disp_mode, $total);
// 1.2 Defines offsets for the next and previous pages
if ($is_display['nav_bar'] == '1') {
if ($_SESSION['tmp_user_values']['max_rows'] == 'all') {
$pos_next = 0;
$pos_prev = 0;
} else {
$pos_next = $_SESSION['tmp_user_values']['pos'] + $_SESSION['tmp_user_values']['max_rows'];
$pos_prev = $_SESSION['tmp_user_values']['pos'] - $_SESSION['tmp_user_values']['max_rows'];
if ($pos_prev < 0) {
$pos_prev = 0;
}
}
}
// end if
// 1.3 Find the sort expression
// we need $sort_expression and $sort_expression_nodirection
// even if there are many table references
if (!empty($analyzed_sql[0]['order_by_clause'])) {
$sort_expression = trim(str_replace(' ', ' ', $analyzed_sql[0]['order_by_clause']));
/**
* Get rid of ASC|DESC
*/
preg_match('@(.*)([[:space:]]*(ASC|DESC))@si', $sort_expression, $matches);
$sort_expression_nodirection = isset($matches[1]) ? trim($matches[1]) : $sort_expression;
$sort_direction = isset($matches[2]) ? trim($matches[2]) : '';
unset($matches);
} else {
$sort_expression = $sort_expression_nodirection = $sort_direction = '';
}
// 1.4 Prepares display of first and last value of the sorted column
if (!empty($sort_expression_nodirection)) {
list($sort_table, $sort_column) = explode('.', $sort_expression_nodirection);
$sort_table = PMA_unQuote($sort_table);
$sort_column = PMA_unQuote($sort_column);
// find the sorted column index in row result
// (this might be a multi-table query)
$sorted_column_index = false;
foreach ($fields_meta as $key => $meta) {
if ($meta->table == $sort_table && $meta->name == $sort_column) {
$sorted_column_index = $key;
//.........这里部分代码省略.........
示例2: PMA_analyseShowGrant
/**
* sets privilege information extracted from SHOW GRANTS result
*
* Detection for some CREATE privilege.
*
* Since MySQL 4.1.2, we can easily detect current user's grants using $userlink
* (no control user needed) and we don't have to try any other method for
* detection
*
* @todo fix to get really all privileges, not only explicitly defined for this user
* from MySQL manual: (http://dev.mysql.com/doc/refman/5.0/en/show-grants.html)
* SHOW GRANTS displays only the privileges granted explicitly to the named
* account. Other privileges might be available to the account, but they are not
* displayed. For example, if an anonymous account exists, the named account
* might be able to use its privileges, but SHOW GRANTS will not display them.
*
* @uses $_SESSION['is_create_db_priv'] for caching
* @uses $_SESSION['is_process_priv'] for caching
* @uses $_SESSION['is_reload_priv'] for caching
* @uses $_SESSION['db_to_create'] for caching
* @uses $_SESSION['dbs_where_create_table_allowed'] for caching
* @uses $GLOBALS['is_create_db_priv'] to set it
* @uses $GLOBALS['is_process_priv'] to set it
* @uses $GLOBALS['is_reload_priv'] to set it
* @uses $GLOBALS['db_to_create'] to set it
* @uses $GLOBALS['dbs_where_create_table_allowed'] to set it
* @uses $GLOBALS['server']
* @uses PMA_DBI_try_query()
* @uses PMA_DBI_fetch_row()
* @uses PMA_DBI_free_result()
* @uses PMA_DBI_getError()
* @uses PMA_unQuote()
* @uses PMA_backquote()
* @uses preg_match()
* @uses preg_replace()
* @uses substr()
* @uses strpos()
*/
function PMA_analyseShowGrant()
{
if (PMA_cacheExists('is_create_db_priv', true)) {
$GLOBALS['is_create_db_priv'] = PMA_cacheGet('is_create_db_priv', true);
$GLOBALS['is_process_priv'] = PMA_cacheGet('is_process_priv', true);
$GLOBALS['is_reload_priv'] = PMA_cacheGet('is_reload_priv', true);
$GLOBALS['db_to_create'] = PMA_cacheGet('db_to_create', true);
$GLOBALS['dbs_where_create_table_allowed'] = PMA_cacheGet('dbs_where_create_table_allowed', true);
return;
}
// defaults
$GLOBALS['is_create_db_priv'] = false;
$GLOBALS['is_process_priv'] = true;
$GLOBALS['is_reload_priv'] = false;
$GLOBALS['db_to_create'] = '';
$GLOBALS['dbs_where_create_table_allowed'] = array();
$rs_usr = PMA_DBI_try_query('SHOW GRANTS');
if (!$rs_usr) {
return;
}
$re0 = '(^|(\\\\\\\\)+|[^\\\\])';
// non-escaped wildcards
$re1 = '(^|[^\\\\])(\\\\)+';
// escaped wildcards
while ($row = PMA_DBI_fetch_row($rs_usr)) {
// extract db from GRANT ... ON *.* or GRANT ... ON db.*
$db_name_offset = strpos($row[0], ' ON ') + 4;
$show_grants_dbname = substr($row[0], $db_name_offset, strpos($row[0], '.', $db_name_offset) - $db_name_offset);
$show_grants_dbname = PMA_unQuote($show_grants_dbname, '`');
$show_grants_str = substr($row[0], 6, strpos($row[0], ' ON ') - 6);
if ($show_grants_str == 'RELOAD') {
$GLOBALS['is_reload_priv'] = true;
}
/**
* @todo if we find CREATE VIEW but not CREATE, do not offer
* the create database dialog box
*/
if ($show_grants_str == 'ALL' || $show_grants_str == 'ALL PRIVILEGES' || $show_grants_str == 'CREATE' || strpos($show_grants_str, 'CREATE,') !== false) {
if ($show_grants_dbname == '*') {
// a global CREATE privilege
$GLOBALS['is_create_db_priv'] = true;
$GLOBALS['is_reload_priv'] = true;
$GLOBALS['db_to_create'] = '';
$GLOBALS['dbs_where_create_table_allowed'][] = '*';
// @todo we should not break here, cause GRANT ALL *.*
// could be revoked by a later rule like GRANT SELECT ON db.*
break;
} else {
// this array may contain wildcards
$GLOBALS['dbs_where_create_table_allowed'][] = $show_grants_dbname;
$dbname_to_test = PMA_backquote($show_grants_dbname);
if ($GLOBALS['is_create_db_priv']) {
// no need for any more tests if we already know this
continue;
}
if (preg_match('/' . $re0 . '%|_/', $show_grants_dbname) && !preg_match('/\\\\%|\\\\_/', $show_grants_dbname) || !PMA_DBI_try_query('USE ' . preg_replace('/' . $re1 . '(%|_)/', '\\1\\3', $dbname_to_test)) && substr(PMA_DBI_getError(), 1, 4) != 1044) {
if ($GLOBALS['cfg']['SuggestDBName']) {
$GLOBALS['db_to_create'] = preg_replace('/' . $re0 . '_/', '\\1?', $show_grants_dbname);
$GLOBALS['db_to_create'] = preg_replace('/' . $re0 . '%/', '\\1...', $GLOBALS['db_to_create']);
$GLOBALS['db_to_create'] = preg_replace('/' . $re1 . '(%|_)/', '\\1\\3', $GLOBALS['db_to_create']);
}
$GLOBALS['is_create_db_priv'] = true;
//.........这里部分代码省略.........
示例3: PMA_SQP_analyze
//.........这里部分代码省略.........
$seen_from = TRUE;
$previous_was_identifier = FALSE;
$save_table_ref = TRUE;
} // end if (data == FROM)
// here, do not 'continue' the loop, as we have more work for
// reserved words below
} // end if (type == alpha_reservedWord)
// ==============================
if ($arr[$i]['type'] == 'quote_backtick'
|| $arr[$i]['type'] == 'quote_double'
|| $arr[$i]['type'] == 'quote_single'
|| $arr[$i]['type'] == 'alpha_identifier'
|| ($arr[$i]['type'] == 'alpha_reservedWord'
&& $arr[$i]['forbidden'] == FALSE)) {
switch ($arr[$i]['type']) {
case 'alpha_identifier':
case 'alpha_reservedWord':
/**
* this is not a real reservedWord, because it's not
* present in the list of forbidden words, for example
* "storage" which can be used as an identifier
*
* @todo avoid the pretty printing in color in this case
*/
$identifier = $arr[$i]['data'];
break;
case 'quote_backtick':
case 'quote_double':
case 'quote_single':
$identifier = PMA_unQuote($arr[$i]['data']);
break;
} // end switch
if ($subresult['querytype'] == 'SELECT'
&& ! $in_group_concat
&& ! ($seen_subquery && $arr[$i - 1]['type'] == 'punct_bracket_close_round')) {
if (!$seen_from) {
if ($previous_was_identifier && isset($chain)) {
// found alias for this select_expr, save it
// but only if we got something in $chain
// (for example, SELECT COUNT(*) AS cnt
// puts nothing in $chain, so we avoid
// setting the alias)
$alias_for_select_expr = $identifier;
} else {
$chain[] = $identifier;
$previous_was_identifier = TRUE;
} // end if !$previous_was_identifier
} else {
// ($seen_from)
if ($save_table_ref && !$seen_end_of_table_ref) {
if ($previous_was_identifier) {
// found alias for table ref
// save it for later
$alias_for_table_ref = $identifier;
} else {
$chain[] = $identifier;
$previous_was_identifier = TRUE;
} // end if ($previous_was_identifier)
} // end if ($save_table_ref &&!$seen_end_of_table_ref)
示例4: testUnQuoteSelectedChar
/**
* unQuote test with chosen quote
* @dataProvider unQuoteSelectedProvider
*/
public function testUnQuoteSelectedChar($param, $expected)
{
$this->assertEquals($expected, PMA_unQuote($param, '"'));
}
示例5: PMA_lookForUse
/**
* Looks for the presence of USE to possibly change current db
*
* @param string $buffer buffer to examine
* @param string $db current db
* @param bool $reload reload
*
* @return array (current or new db, whether to reload)
* @access public
*/
function PMA_lookForUse($buffer, $db, $reload)
{
if (preg_match('@^[\\s]*USE[[:space:]]+([\\S]+)@i', $buffer, $match)) {
$db = trim($match[1]);
$db = trim($db, ';');
// for example, USE abc;
// $db must not contain the escape characters generated by PMA_backquote()
// ( used in PMA_buildSQL() as: PMA_backquote($db_name), and then called
// in PMA_importRunQuery() which in turn calls PMA_lookForUse() )
$db = PMA_unQuote($db);
$reload = true;
}
return array($db, $reload);
}