本文整理汇总了PHP中PMA_SQP_formatHtml函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_SQP_formatHtml函数的具体用法?PHP PMA_SQP_formatHtml怎么用?PHP PMA_SQP_formatHtml使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_SQP_formatHtml函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PMA_transformation_text_plain__sql
function PMA_transformation_text_plain__sql($buffer, $options = array(), $meta = '')
{
$result = PMA_SQP_formatHtml(PMA_SQP_parse($buffer));
// Need to clear error state not to break subsequent queries display.
PMA_SQP_resetError();
return $result;
}
示例2: html
public static function html($_sql, $removeNewLines = false)
{
global $settings;
if (!$settings['sqlColor']) {
return $_sql;
}
try {
$_sql = PMA_SQP_formatHtml(self::parsePMA($_sql));
if ($removeNewLines) {
$sql = str_replace(array('<br>', '<br/>', '<br />'), ' ', $_sql);
$sql = str_replace('<div', ' <span', $_sql);
}
return $_sql;
} catch (exception $e) {
return $_sql;
}
}
示例3: executeQuery
function executeQuery($queryOrQueryAndParams)
{
global $trackDbSpeed, $traceSqlQueries, $sqlQueryDump, $dbPrefix, $dbClasses;
if (is_array($queryOrQueryAndParams)) {
$query = array_shift($queryOrQueryAndParams);
$args = $queryOrQueryAndParams;
} else {
$query = $queryOrQueryAndParams;
$args = func_get_args();
if (count($args) > 1) {
array_shift($args);
} else {
$args = array();
}
}
$query = preg_replace("/@(" . implode("|", $dbClasses) . ")/", "{$dbPrefix}\$1", $query);
if (count($args)) {
$query = preg_replace(array("/'%/", "/%'/"), array("'%%", "%%'"), $query);
$query = preg_replace(array("/#[^#]+#/", "/`[^`]+`/"), array("'%s'", "`%s`"), $query);
$query = vsprintf($query, array_map("quoteSQL", $args));
}
if (isset($trackDbSpeed) && $trackDbSpeed) {
$result = speedTrackExecuteQuery($query);
} else {
$result = mysql_query($query);
}
if ($result == 0) {
handleErrorSql($query);
}
if ($traceSqlQueries) {
require_once GORUM_DIR . "/sqlparser.php";
$parsed_sql = PMA_SQP_parse($query);
$sqlQueryDump .= PMA_SQP_formatHtml($parsed_sql);
$sqlQueryDump .= "<br><br>";
}
return $result;
}
示例4: moveCopy
//.........这里部分代码省略.........
// REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI
if (false !== strpos($server_sql_mode, 'ANSI_QUOTES')) {
$table_delimiter = 'quote_double';
} else {
$table_delimiter = 'quote_backtick';
}
unset($server_sql_mode);
}
/* Find table name in query and replace it */
while ($parsed_sql[$i]['type'] != $table_delimiter) {
$i++;
}
/* no need to backquote() */
if (isset($target_for_view)) {
// this a view definition; we just found the first db name
// that follows DEFINER VIEW
// so change it for the new db name
$parsed_sql[$i]['data'] = $target_for_view;
// then we have to find all references to the source db
// and change them to the target db, ensuring we stay into
// the $parsed_sql limits
$last = $parsed_sql['len'] - 1;
$backquoted_source_db = PMA_Util::backquote($source_db);
for (++$i; $i <= $last; $i++) {
if ($parsed_sql[$i]['type'] == $table_delimiter && $parsed_sql[$i]['data'] == $backquoted_source_db && $parsed_sql[$i - 1]['type'] != 'punct_qualifier') {
$parsed_sql[$i]['data'] = $target_for_view;
}
}
unset($last, $backquoted_source_db);
} else {
$parsed_sql[$i]['data'] = $target;
}
/* Generate query back */
$sql_structure = PMA_SQP_formatHtml($parsed_sql, 'query_only');
// If table exists, and 'add drop table' is selected: Drop it!
$drop_query = '';
if (isset($_REQUEST['drop_if_exists']) && $_REQUEST['drop_if_exists'] == 'true') {
if (PMA_Table::isView($target_db, $target_table)) {
$drop_query = 'DROP VIEW';
} else {
$drop_query = 'DROP TABLE';
}
$drop_query .= ' IF EXISTS ' . PMA_Util::backquote($target_db) . '.' . PMA_Util::backquote($target_table);
PMA_DBI_query($drop_query);
$GLOBALS['sql_query'] .= "\n" . $drop_query . ';';
// If an existing table gets deleted, maintain any
// entries for the PMA_* tables
$maintain_relations = true;
}
@PMA_DBI_query($sql_structure);
$GLOBALS['sql_query'] .= "\n" . $sql_structure . ';';
if (($move || isset($GLOBALS['add_constraints'])) && !empty($GLOBALS['sql_constraints_query'])) {
$parsed_sql = PMA_SQP_parse($GLOBALS['sql_constraints_query']);
$i = 0;
// find the first $table_delimiter, it must be the source
// table name
while ($parsed_sql[$i]['type'] != $table_delimiter) {
$i++;
// maybe someday we should guard against going over limit
//if ($i == $parsed_sql['len']) {
// break;
//}
}
// replace it by the target table name, no need
// to backquote()
$parsed_sql[$i]['data'] = $target;
示例5: getServerTrafficHtml
//.........这里部分代码省略.........
if (PMA_DRIZZLE) {
$sql_query = "SELECT\n p.id AS Id,\n p.username AS User,\n p.host AS Host,\n p.db AS db,\n p.command AS Command,\n p.time AS Time,\n p.state AS State,\n " . ($show_full_sql ? 's.query' : 'left(p.info, ' . (int) $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] . ')') . " AS Info\n FROM data_dictionary.PROCESSLIST p\n " . ($show_full_sql ? 'LEFT JOIN data_dictionary.SESSIONS s ON s.session_id = p.id' : '');
if (!empty($_REQUEST['order_by_field']) && !empty($_REQUEST['sort_order'])) {
$sql_query .= ' ORDER BY p.' . $_REQUEST['order_by_field'] . ' ' . $_REQUEST['sort_order'];
}
} else {
$sql_query = $show_full_sql ? 'SHOW FULL PROCESSLIST' : 'SHOW PROCESSLIST';
if (!empty($_REQUEST['order_by_field']) && !empty($_REQUEST['sort_order'])) {
$sql_query = 'SELECT * FROM `INFORMATION_SCHEMA`.`PROCESSLIST` ORDER BY `' . $_REQUEST['order_by_field'] . '` ' . $_REQUEST['sort_order'];
}
}
$result = PMA_DBI_query($sql_query);
/**
* Displays the page
*/
$retval .= '<table id="tableprocesslist" class="data clearfloat noclick sortable">';
$retval .= '<thead>';
$retval .= '<tr>';
$retval .= '<th>' . __('Processes') . '</th>';
foreach ($sortable_columns as $column) {
$is_sorted = !empty($_REQUEST['order_by_field']) && !empty($_REQUEST['sort_order']) && $_REQUEST['order_by_field'] == $column['order_by_field'];
$column['sort_order'] = 'ASC';
if ($is_sorted && $_REQUEST['sort_order'] === 'ASC') {
$column['sort_order'] = 'DESC';
}
if ($is_sorted) {
if ($_REQUEST['sort_order'] == 'ASC') {
$asc_display_style = 'inline';
$desc_display_style = 'none';
} elseif ($_REQUEST['sort_order'] == 'DESC') {
$desc_display_style = 'inline';
$asc_display_style = 'none';
}
}
$retval .= '<th>';
$retval .= '<a href="server_status.php' . PMA_generate_common_url($column) . '" ';
if ($is_sorted) {
$retval .= 'onmouseout="$(\'.soimg\').toggle()" ' . 'onmouseover="$(\'.soimg\').toggle()"';
}
$retval .= '>';
$retval .= $column['column_name'];
if ($is_sorted) {
$retval .= '<img class="icon ic_s_desc soimg" alt="' . __('Descending') . '" title="" src="themes/dot.gif" ' . 'style="display: ' . $desc_display_style . '" />';
$retval .= '<img class="icon ic_s_asc soimg hide" alt="' . __('Ascending') . '" title="" src="themes/dot.gif" ' . 'style="display: ' . $asc_display_style . '" />';
}
$retval .= '</a>';
if (!PMA_DRIZZLE && 0 === --$sortable_columns_count) {
$retval .= '<a href="' . $full_text_link . '">';
if ($show_full_sql) {
$retval .= PMA_Util::getImage('s_partialtext.png', __('Truncate Shown Queries'));
} else {
$retval .= PMA_Util::getImage('s_fulltext.png', __('Show Full Queries'));
}
$retval .= '</a>';
}
$retval .= '</th>';
}
$retval .= '</tr>';
$retval .= '</thead>';
$retval .= '<tbody>';
$odd_row = true;
while ($process = PMA_DBI_fetch_assoc($result)) {
// Array keys need to modify due to the way it has used
// to display column values
if (!empty($_REQUEST['order_by_field']) && !empty($_REQUEST['sort_order'])) {
foreach (array_keys($process) as $key) {
$new_key = ucfirst(strtolower($key));
$process[$new_key] = $process[$key];
unset($process[$key]);
}
}
$url_params['kill'] = $process['Id'];
$kill_process = 'server_status.php' . PMA_generate_common_url($url_params);
$retval .= '<tr class="' . ($odd_row ? 'odd' : 'even') . '">';
$retval .= '<td><a href="' . $kill_process . '">' . __('Kill') . '</a></td>';
$retval .= '<td class="value">' . $process['Id'] . '</td>';
$retval .= '<td>' . htmlspecialchars($process['User']) . '</td>';
$retval .= '<td>' . htmlspecialchars($process['Host']) . '</td>';
$retval .= '<td>' . (!isset($process['db']) || !strlen($process['db']) ? '<i>' . __('None') . '</i>' : htmlspecialchars($process['db'])) . '</td>';
$retval .= '<td>' . htmlspecialchars($process['Command']) . '</td>';
$retval .= '<td class="value">' . $process['Time'] . '</td>';
$retval .= '<td>' . (empty($process['State']) ? '---' : $process['State']) . '</td>';
$retval .= '<td>';
if (empty($process['Info'])) {
$retval .= '---';
} else {
if (!$show_full_sql && strlen($process['Info']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
$retval .= htmlspecialchars(substr($process['Info'], 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'])) . '[...]';
} else {
$retval .= PMA_SQP_formatHtml(PMA_SQP_parse($process['Info']));
}
}
$retval .= '</td>';
$retval .= '</tr>';
$odd_row = !$odd_row;
}
$retval .= '</tbody>';
$retval .= '</table>';
return $retval;
}
示例6: empty
echo !isset($process['db']) || !strlen($process['db']) ? '<i>' . $strNone . '</i>' : $process['db'];
?>
</td>
<td><?php
echo $process['Command'];
?>
</td>
<td class="value"><?php
echo $process['Time'];
?>
</td>
<td><?php
echo empty($process['State']) ? '---' : $process['State'];
?>
</td>
<td><?php
echo empty($process['Info']) ? '---' : PMA_SQP_formatHtml(PMA_SQP_parse($process['Info']));
?>
</td>
</tr>
<?php
$odd_row = !$odd_row;
}
?>
</tbody>
</table>
<?php
/**
* Sends the footer
*/
require_once './libraries/footer.inc.php';
示例7: PMA_formatSql
/**
* format sql strings
*
* @param mixed pre-parsed SQL structure
*
* @return string the formatted sql
*
* @global array the configuration array
* @global boolean whether the current statement is a multiple one or not
*
* @access public
*
* @author Robin Johnson <robbat2@users.sourceforge.net>
*/
function PMA_formatSql($parsed_sql, $unparsed_sql = '')
{
global $cfg;
// Check that we actually have a valid set of parsed data
// well, not quite
// first check for the SQL parser having hit an error
if (PMA_SQP_isError()) {
return $parsed_sql;
}
// then check for an array
if (!is_array($parsed_sql)) {
// We don't so just return the input directly
// This is intended to be used for when the SQL Parser is turned off
$formatted_sql = '<pre>' . "\n" . ($cfg['SQP']['fmtType'] == 'none' && $unparsed_sql != '' ? $unparsed_sql : $parsed_sql) . "\n" . '</pre>';
return $formatted_sql;
}
$formatted_sql = '';
switch ($cfg['SQP']['fmtType']) {
case 'none':
if ($unparsed_sql != '') {
$formatted_sql = "<pre>\n" . PMA_SQP_formatNone(array('raw' => $unparsed_sql)) . "\n</pre>";
} else {
$formatted_sql = PMA_SQP_formatNone($parsed_sql);
}
break;
case 'html':
$formatted_sql = PMA_SQP_formatHtml($parsed_sql, 'color');
break;
case 'text':
//$formatted_sql = PMA_SQP_formatText($parsed_sql);
$formatted_sql = PMA_SQP_formatHtml($parsed_sql, 'text');
break;
default:
break;
}
// end switch
return $formatted_sql;
}
示例8: formatSql
/**
* format sql strings
*
* @param mixed $parsed_sql pre-parsed SQL structure
* @param string $unparsed_sql raw SQL string
*
* @return string the formatted sql
*
* @global array the configuration array
* @global boolean whether the current statement is a multiple one or not
*
* @access public
* @todo move into PMA_Sql
*/
public static function formatSql($parsed_sql, $unparsed_sql = '')
{
global $cfg;
// Check that we actually have a valid set of parsed data
// well, not quite
// first check for the SQL parser having hit an error
if (PMA_SQP_isError()) {
return htmlspecialchars($parsed_sql['raw']);
}
// then check for an array
if (! is_array($parsed_sql)) {
// We don't so just return the input directly
// This is intended to be used for when the SQL Parser is turned off
$formatted_sql = "<pre>\n";
if (($cfg['SQP']['fmtType'] == 'none') && ($unparsed_sql != '')) {
$formatted_sql .= $unparsed_sql;
} else {
$formatted_sql .= $parsed_sql;
}
$formatted_sql .= "\n</pre>";
return $formatted_sql;
}
$formatted_sql = '';
switch ($cfg['SQP']['fmtType']) {
case 'none':
if ($unparsed_sql != '') {
$formatted_sql = '<span class="inner_sql"><pre>' . "\n"
. PMA_SQP_formatNone(array('raw' => $unparsed_sql)) . "\n"
. '</pre></span>';
} else {
$formatted_sql = PMA_SQP_formatNone($parsed_sql);
}
break;
case 'html':
$formatted_sql = PMA_SQP_formatHtml($parsed_sql, 'color');
break;
case 'text':
$formatted_sql = PMA_SQP_formatHtml($parsed_sql, 'text');
break;
default:
break;
} // end switch
return $formatted_sql;
} // end of the "formatSql()" function
示例9: SQLFormatPHP
function SQLFormatPHP($in)
{
return PMA_SQP_formatHtml(PMA_SQP_parse($in), 'text');
}
示例10: empty
echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
?>
" align="right"> <?php
echo $value['Time'];
?>
</td>
<td bgcolor="<?php
echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
?>
"> <?php
echo empty($value['State']) ? '---' : $value['State'];
?>
</td>
<td bgcolor="<?php
echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
?>
"> <?php
echo empty($value['Info']) ? '---' : PMA_SQP_formatHtml(PMA_SQP_parse($value['Info']));
?>
</td>
</tr>
<?php
$useBgcolorOne = !$useBgcolorOne;
}
?>
</table>
<?php
/**
* Sends the footer
*/
require_once './footer.inc.php';
示例11: PMA_table_move_copy
/**
* Copies or renames table
* FIXME: use RENAME
*
* @author Michal Čihař <michal@cihar.com>
*/
function PMA_table_move_copy($source_db, $source_table, $target_db, $target_table, $what, $move)
{
global $cfgRelation, $dblist, $err_url, $sql_query;
// set export settings we need
$GLOBALS['use_backquotes'] = 1;
$GLOBALS['asfile'] = 1;
// Ensure the target is valid
if (count($dblist) > 0 && (PMA_isInto($source_db, $dblist) == -1 || PMA_isInto($target_db, $dblist) == -1)) {
exit;
}
$source = PMA_backquote($source_db) . '.' . PMA_backquote($source_table);
if (empty($target_db)) {
$target_db = $source_db;
}
// This could avoid some problems with replicated databases, when
// moving table from replicated one to not replicated one
PMA_DBI_select_db($target_db);
$target = PMA_backquote($target_db) . '.' . PMA_backquote($target_table);
// do not create the table if dataonly
if ($what != 'dataonly') {
require_once './libraries/export/sql.php';
$no_constraints_comments = true;
$sql_structure = PMA_getTableDef($source_db, $source_table, "\n", $err_url);
unset($no_constraints_comments);
$parsed_sql = PMA_SQP_parse($sql_structure);
/* nijel: Find table name in query and replace it */
$i = 0;
while ($parsed_sql[$i]['type'] != 'quote_backtick') {
$i++;
}
/* no need to PMA_backquote() */
$parsed_sql[$i]['data'] = $target;
/* Generate query back */
$sql_structure = PMA_SQP_formatHtml($parsed_sql, 'query_only');
// If table exists, and 'add drop table' is selected: Drop it!
$drop_query = '';
if (isset($GLOBALS['drop_if_exists']) && $GLOBALS['drop_if_exists'] == 'true') {
$drop_query = 'DROP TABLE IF EXISTS ' . PMA_backquote($target_db) . '.' . PMA_backquote($target_table);
$result = PMA_DBI_query($drop_query);
if (isset($sql_query)) {
$sql_query .= "\n" . $drop_query . ';';
} else {
$sql_query = $drop_query . ';';
}
// garvin: If an existing table gets deleted, maintain any entries
// for the PMA_* tables
$maintain_relations = TRUE;
}
$result = @PMA_DBI_query($sql_structure);
if (isset($sql_query)) {
$sql_query .= "\n" . $sql_structure . ';';
} else {
$sql_query = $sql_structure . ';';
}
if (($move || isset($GLOBALS['constraints'])) && isset($GLOBALS['sql_constraints'])) {
$parsed_sql = PMA_SQP_parse($GLOBALS['sql_constraints']);
$i = 0;
while ($parsed_sql[$i]['type'] != 'quote_backtick') {
$i++;
}
/* no need to PMA_backquote() */
$parsed_sql[$i]['data'] = $target;
/* Generate query back */
$GLOBALS['sql_constraints'] = PMA_SQP_formatHtml($parsed_sql, 'query_only');
$result = PMA_DBI_query($GLOBALS['sql_constraints']);
if (isset($sql_query)) {
$sql_query .= "\n" . $GLOBALS['sql_constraints'];
} else {
$sql_query = $GLOBALS['sql_constraints'];
}
unset($GLOBALS['sql_constraints']);
}
} else {
$sql_query = '';
}
// Copy the data
//if ($result != FALSE && ($what == 'data' || $what == 'dataonly')) {
if ($what == 'data' || $what == 'dataonly') {
$sql_insert_data = 'INSERT INTO ' . $target . ' SELECT * FROM ' . $source;
PMA_DBI_query($sql_insert_data);
$sql_query .= "\n\n" . $sql_insert_data . ';';
}
require_once './libraries/relation.lib.php';
$cfgRelation = PMA_getRelationsParam();
// Drops old table if the user has requested to move it
if ($move) {
// This could avoid some problems with replicated databases, when
// moving table from replicated one to not replicated one
PMA_DBI_select_db($source_db);
$sql_drop_table = 'DROP TABLE ' . $source;
PMA_DBI_query($sql_drop_table);
// garvin: Move old entries from PMA-DBs to new table
if ($cfgRelation['commwork']) {
$remove_query = 'UPDATE ' . PMA_backquote($cfgRelation['column_info']) . ' SET table_name = \'' . PMA_sqlAddslashes($target_table) . '\', ' . ' db_name = \'' . PMA_sqlAddslashes($target_db) . '\'' . ' WHERE db_name = \'' . PMA_sqlAddslashes($source_db) . '\'' . ' AND table_name = \'' . PMA_sqlAddslashes($source_table) . '\'';
//.........这里部分代码省略.........
示例12: SQLFormatPHP
function SQLFormatPHP($sql)
{
return PMA_SQP_formatHtml(PMA_SQP_parse($sql));
}
示例13: printServerTraffic
//.........这里部分代码省略.........
</th>
<th><?php
echo __('Status');
?>
</th>
<th><?php
echo __('SQL query');
if (!PMA_DRIZZLE) {
?>
<a href="<?php
echo $full_text_link;
?>
"
title="<?php
echo $show_full_sql ? __('Truncate Shown Queries') : __('Show Full Queries');
?>
">
<img src="<?php
echo $GLOBALS['pmaThemeImage'] . 's_' . ($show_full_sql ? 'partial' : 'full');
?>
text.png"
alt="<?php
echo $show_full_sql ? __('Truncate Shown Queries') : __('Show Full Queries');
?>
" />
</a>
<?php
}
?>
</th>
</tr>
</thead>
<tbody>
<?php
$odd_row = true;
while ($process = PMA_DBI_fetch_assoc($result)) {
$url_params['kill'] = $process['Id'];
$kill_process = 'server_status.php' . PMA_generate_common_url($url_params);
?>
<tr class="<?php
echo $odd_row ? 'odd' : 'even';
?>
">
<td><a href="<?php
echo $kill_process;
?>
"><?php
echo __('Kill');
?>
</a></td>
<td class="value"><?php
echo $process['Id'];
?>
</td>
<td><?php
echo $process['User'];
?>
</td>
<td><?php
echo $process['Host'];
?>
</td>
<td><?php
echo !isset($process['db']) || !strlen($process['db']) ? '<i>' . __('None') . '</i>' : $process['db'];
?>
</td>
<td><?php
echo $process['Command'];
?>
</td>
<td class="value"><?php
echo $process['Time'];
?>
</td>
<td><?php
echo empty($process['State']) ? '---' : $process['State'];
?>
</td>
<td>
<?php
if (empty($process['Info'])) {
echo '---';
} else {
if (!$show_full_sql && strlen($process['Info']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
echo htmlspecialchars(substr($process['Info'], 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'])) . '[...]';
} else {
echo PMA_SQP_formatHtml(PMA_SQP_parse($process['Info']));
}
}
?>
</td>
</tr>
<?php
$odd_row = !$odd_row;
}
?>
</tbody>
</table>
<?php
}
示例14: moveCopy
/**
* Copies or renames table
* @todo use RENAME for move operations
* - would work only if the databases are on the same filesystem,
* how can we check that? try the operation and
* catch an error?
* - for views, only if MYSQL > 50013
* - still have to handle pmadb synch.
*
* @author Michal Cihar <michal@cihar.com>
*/
function moveCopy($source_db, $source_table, $target_db, $target_table, $what, $move, $mode)
{
global $err_url;
// set export settings we need
$GLOBALS['sql_backquotes'] = 1;
$GLOBALS['asfile'] = 1;
// Ensure the target is valid
if (!$GLOBALS['PMA_List_Database']->exists($source_db, $target_db)) {
/**
* @todo exit really needed here? or just a return?
*/
exit;
}
$source = PMA_backquote($source_db) . '.' . PMA_backquote($source_table);
if (!isset($target_db) || !strlen($target_db)) {
$target_db = $source_db;
}
// Doing a select_db could avoid some problems with replicated databases,
// when moving table from replicated one to not replicated one
PMA_DBI_select_db($target_db);
$target = PMA_backquote($target_db) . '.' . PMA_backquote($target_table);
// do not create the table if dataonly
if ($what != 'dataonly') {
require_once './libraries/export/sql.php';
$no_constraints_comments = true;
$GLOBALS['sql_constraints_query'] = '';
$sql_structure = PMA_getTableDef($source_db, $source_table, "\n", $err_url);
unset($no_constraints_comments);
$parsed_sql = PMA_SQP_parse($sql_structure);
$analyzed_sql = PMA_SQP_analyze($parsed_sql);
$i = 0;
if (empty($analyzed_sql[0]['create_table_fields'])) {
// this is not a CREATE TABLE, so find the first VIEW
$target_for_view = PMA_backquote($target_db);
while (true) {
if ($parsed_sql[$i]['type'] == 'alpha_reservedWord' && $parsed_sql[$i]['data'] == 'VIEW') {
break;
}
$i++;
}
}
unset($analyzed_sql);
$server_sql_mode = PMA_DBI_fetch_value("SHOW VARIABLES LIKE 'sql_mode'", 0, 1);
if ('ANSI_QUOTES' == $server_sql_mode) {
$table_delimiter = 'quote_double';
} else {
$table_delimiter = 'quote_backtick';
}
unset($server_sql_mode);
/* nijel: Find table name in query and replace it */
while ($parsed_sql[$i]['type'] != $table_delimiter) {
$i++;
}
/* no need to PMA_backquote() */
if (isset($target_for_view)) {
// this a view definition; we just found the first db name
// that follows DEFINER VIEW
// so change it for the new db name
$parsed_sql[$i]['data'] = $target_for_view;
// then we have to find all references to the source db
// and change them to the target db, ensuring we stay into
// the $parsed_sql limits
$last = $parsed_sql['len'] - 1;
$backquoted_source_db = PMA_backquote($source_db);
for (++$i; $i <= $last; $i++) {
if ($parsed_sql[$i]['type'] == $table_delimiter && $parsed_sql[$i]['data'] == $backquoted_source_db) {
$parsed_sql[$i]['data'] = $target_for_view;
}
}
unset($last, $backquoted_source_db);
} else {
$parsed_sql[$i]['data'] = $target;
}
/* Generate query back */
$sql_structure = PMA_SQP_formatHtml($parsed_sql, 'query_only');
// If table exists, and 'add drop table' is selected: Drop it!
$drop_query = '';
if (isset($GLOBALS['drop_if_exists']) && $GLOBALS['drop_if_exists'] == 'true') {
if (PMA_Table::_isView($target_db, $target_table)) {
$drop_query = 'DROP VIEW';
} else {
$drop_query = 'DROP TABLE';
}
$drop_query .= ' IF EXISTS ' . PMA_backquote($target_db) . '.' . PMA_backquote($target_table);
PMA_DBI_query($drop_query);
$GLOBALS['sql_query'] .= "\n" . $drop_query . ';';
// garvin: If an existing table gets deleted, maintain any
// entries for the PMA_* tables
$maintain_relations = true;
//.........这里部分代码省略.........
示例15: PMA_SQP_parse
if (isset($sql_query)) {
$sql_query .= "\n" . $sql_structure . ';';
} else {
$sql_query = $sql_structure . ';';
}
}
if ((isset($submit_move) || isset($constraints)) && isset($sql_constraints)) {
$parsed_sql = PMA_SQP_parse($sql_constraints);
$i = 0;
while ($parsed_sql[$i]['type'] != 'quote_backtick') {
$i++;
}
/* no need to PMA_backquote() */
$parsed_sql[$i]['data'] = $target;
/* Generate query back */
$sql_constraints = PMA_SQP_formatHtml($parsed_sql, 'query_only');
$result = @PMA_mysql_query($sql_constraints);
if (PMA_mysql_error()) {
require_once './header.inc.php';
PMA_mysqlDie('', $sql_structure, '', $err_url);
} else {
if (isset($sql_query)) {
$sql_query .= "\n" . $sql_constraints;
} else {
$sql_query = $sql_constraints;
}
}
}
} else {
$sql_query = '';
}