2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * set of functions for the sql executor
8 if (!defined('PHPMYADMIN')) {
13 * Get the database name inside a query
15 * @param string $sql SQL query
16 * @param array $databases array with all databases
18 * @return string $db new database name
20 function PMA_getNewDatabase($sql, $databases)
23 // loop through all the databases
24 foreach ($databases as $database) {
25 if (strpos($sql, $database['SCHEMA_NAME']) !== false) {
26 $db = $database['SCHEMA_NAME'];
34 * Get the table name in a sql query
35 * If there are several tables in the SQL query,
36 * first table wil lreturn
38 * @param string $sql SQL query
39 * @param array $tables array of names in current database
41 * @return string $table table name
43 function PMA_getTableNameBySQL($sql, $tables)
47 // loop through all the tables in the database
48 foreach ($tables as $tbl) {
49 if (strpos($sql, $tbl)) {
54 if (count(explode(' ', trim($table))) > 1) {
55 $tmp_array = explode(' ', trim($table));
64 * Generate table html when SQL statement have multiple queries
65 * which return displayable results
67 * @param object $displayResultsObject PMA_DisplayResults object
68 * @param string $db database name
69 * @param array $sql_data information about SQL statement
70 * @param string $goto URL to go back in case of errors
71 * @param string $pmaThemeImage path for theme images directory
72 * @param string $printview whether printview is enabled
73 * @param string $url_query URL query
74 * @param array $disp_mode the display mode
75 * @param string $sql_limit_to_append limit clause
76 * @param bool $editable whether editable or not
78 * @return string $table_html html content
80 function PMA_getTableHtmlForMultipleQueries(
81 $displayResultsObject, $db, $sql_data, $goto, $pmaThemeImage,
82 $printview, $url_query, $disp_mode, $sql_limit_to_append,
87 $tables_array = $GLOBALS['dbi']->getTables($db);
88 $databases_array = $GLOBALS['dbi']->getDatabasesFull();
89 $multi_sql = implode(";", $sql_data['valid_sql']);
90 $querytime_before = array_sum(explode(' ', microtime()));
92 // Assignment for variable is not needed since the results are
93 // looping using the connection
94 @$GLOBALS['dbi']->tryMultiQuery($multi_sql);
96 $querytime_after = array_sum(explode(' ', microtime()));
97 $querytime = $querytime_after - $querytime_before;
101 $analyzed_sql = array();
102 $is_affected = false;
104 $result = $GLOBALS['dbi']->storeResult();
105 $fields_meta = ($result !== false)
106 ?
$GLOBALS['dbi']->getFieldsMeta($result)
108 $fields_cnt = count($fields_meta);
110 // Initialize needed params related to each query in multiquery statement
111 if (isset($sql_data['valid_sql'][$sql_no])) {
112 // 'Use' query can change the database
113 if (stripos($sql_data['valid_sql'][$sql_no], "use ")) {
114 $db = PMA_getNewDatabase(
115 $sql_data['valid_sql'][$sql_no],
120 $table = PMA_getTableNameBySQL(
121 $sql_data['valid_sql'][$sql_no],
125 // for the use of the parse_analyze.inc.php
126 $sql_query = $sql_data['valid_sql'][$sql_no];
128 // Parse and analyze the query
129 include 'libraries/parse_analyze.inc.php';
131 $unlim_num_rows = PMA_Table
::countRecords($db, $table, true);
132 $showtable = PMA_Table
::sGetStatusInfo($db, $table, null, true);
133 $url_query = PMA_URL_getCommon($db, $table);
135 // Handle remembered sorting order, only for single table query
136 if ($GLOBALS['cfg']['RememberSorting']
137 && ! ($is_count ||
$is_export ||
$is_func ||
$is_analyse)
138 && isset($analyzed_sql[0]['select_expr'])
139 && (count($analyzed_sql[0]['select_expr']) == 0)
140 && isset($analyzed_sql[0]['queryflags']['select_from'])
141 && count($analyzed_sql[0]['table_ref']) == 1
147 $sql_data['valid_sql'][$sql_no]
151 // Do append a "LIMIT" clause?
152 if (($_SESSION['tmp_user_values']['max_rows'] != 'all')
153 && ! ($is_count ||
$is_export ||
$is_func ||
$is_analyse)
154 && isset($analyzed_sql[0]['queryflags']['select_from'])
155 && ! isset($analyzed_sql[0]['queryflags']['offset'])
156 && empty($analyzed_sql[0]['limit_clause'])
158 $sql_limit_to_append = ' LIMIT '
159 . $_SESSION['tmp_user_values']['pos']
160 . ', ' . $_SESSION['tmp_user_values']['max_rows'] . " ";
161 $sql_data['valid_sql'][$sql_no] = PMA_getSqlWithLimitClause(
162 $sql_data['valid_sql'][$sql_no],
168 // Set the needed properties related to executing sql query
169 $displayResultsObject->__set('db', $db);
170 $displayResultsObject->__set('table', $table);
171 $displayResultsObject->__set('goto', $goto);
174 if (! $is_affected) {
175 $num_rows = ($result) ?
@$GLOBALS['dbi']->numRows($result) : 0;
176 } elseif (! isset($num_rows)) {
177 $num_rows = @$GLOBALS['dbi']->affectedRows();
180 if (isset($sql_data['valid_sql'][$sql_no])) {
182 $displayResultsObject->__set(
184 $sql_data['valid_sql'][$sql_no]
186 $displayResultsObject->setProperties(
187 $unlim_num_rows, $fields_meta, $is_count, $is_export, $is_func,
188 $is_analyse, $num_rows, $fields_cnt, $querytime, $pmaThemeImage,
189 $GLOBALS['text_dir'], $is_maint, $is_explain, $is_show,
190 $showtable, $printview, $url_query, $editable
194 if ($num_rows == 0) {
198 // With multiple results, operations are limied
199 $disp_mode = 'nnnn000000';
200 $is_limited_display = true;
202 // Collect the tables
203 $table_html .= $displayResultsObject->getTable(
204 $result, $disp_mode, $analyzed_sql, $is_limited_display
207 // Free the result to save the memory
208 $GLOBALS['dbi']->freeResult($result);
212 } while ($GLOBALS['dbi']->moreResults() && $GLOBALS['dbi']->nextResult());
218 * Handle remembered sorting order, only for single table query
220 * @param string $db database name
221 * @param string $table table name
222 * @param array &$analyzed_sql_results the analyzed query results
223 * @param string &$full_sql_query SQL query
227 function PMA_handleSortOrder($db, $table, &$analyzed_sql_results, &$full_sql_query)
229 $pmatable = new PMA_Table($table, $db);
230 if (empty($analyzed_sql_results['analyzed_sql'][0]['order_by_clause'])) {
231 $sorted_col = $pmatable->getUiProp(PMA_Table
::PROP_SORTED_COLUMN
);
233 // retrieve the remembered sorting order for current table
234 $sql_order_to_append = ' ORDER BY ' . $sorted_col . ' ';
236 = $analyzed_sql_results['analyzed_sql'][0]['section_before_limit']
237 . $sql_order_to_append
238 . $analyzed_sql_results['analyzed_sql'][0]['limit_clause']
240 . $analyzed_sql_results['analyzed_sql'][0]['section_after_limit'];
242 // update the $analyzed_sql
243 $analyzed_sql_results['analyzed_sql'][0]['section_before_limit']
244 .= $sql_order_to_append;
245 $analyzed_sql_results['analyzed_sql'][0]['order_by_clause']
249 // store the remembered table into session
250 $pmatable->setUiProp(
251 PMA_Table
::PROP_SORTED_COLUMN
,
252 $analyzed_sql_results['analyzed_sql'][0]['order_by_clause']
258 * Append limit clause to SQL query
260 * @param string $full_sql_query SQL query
261 * @param array $analyzed_sql the analyzed query
262 * @param string $sql_limit_to_append clause to append
264 * @return string limit clause appended SQL query
266 function PMA_getSqlWithLimitClause($full_sql_query, $analyzed_sql,
269 return $analyzed_sql[0]['section_before_limit'] . "\n"
270 . $sql_limit_to_append . $analyzed_sql[0]['section_after_limit'];
275 * Get column name from a drop SQL statement
277 * @param string $sql SQL query
279 * @return string $drop_column Name of the column
281 function PMA_getColumnNameInColumnDropSql($sql)
283 $tmpArray1 = explode('DROP', $sql);
284 $str_to_check = trim($tmpArray1[1]);
286 if (stripos($str_to_check, 'COLUMN') !== false) {
287 $tmpArray2 = explode('COLUMN', $str_to_check);
288 $str_to_check = trim($tmpArray2[1]);
291 $tmpArray3 = explode(' ', $str_to_check);
292 $str_to_check = trim($tmpArray3[0]);
294 $drop_column = str_replace(';', '', trim($str_to_check));
295 $drop_column = str_replace('`', '', $drop_column);
301 * Verify whether the result set contains all the columns
302 * of at least one unique key
304 * @param string $db database name
305 * @param string $table table name
306 * @param string $fields_meta meta fields
308 * @return boolean whether the result set contains a unique key
310 function PMA_resultSetContainsUniqueKey($db, $table, $fields_meta)
312 $resultSetColumnNames = array();
313 foreach ($fields_meta as $oneMeta) {
314 $resultSetColumnNames[] = $oneMeta->name
;
316 foreach (PMA_Index
::getFromTable($table, $db) as $index) {
317 if ($index->isUnique()) {
318 $indexColumns = $index->getColumns();
320 foreach ($indexColumns as $indexColumnName => $dummy) {
321 if (in_array($indexColumnName, $resultSetColumnNames)) {
325 if ($numberFound == count($indexColumns)) {
334 * Get the HTML for relational column dropdown
335 * During grid edit, if we have a relational field, returns the html for the
338 * @param string $db current database
339 * @param string $table current table
340 * @param string $column current column
341 * @param string $curr_value current selected value
343 * @return string $dropdown html for the dropdown
345 function PMA_getHtmlForRelationalColumnDropdown($db, $table, $column, $curr_value)
347 $foreigners = PMA_getForeigners($db, $table, $column);
349 $display_field = PMA_getDisplayField(
350 $foreigners[$column]['foreign_db'],
351 $foreigners[$column]['foreign_table']
354 $foreignData = PMA_getForeignData($foreigners, $column, false, '', '');
356 if ($foreignData['disp_row'] == null) {
357 //Handle the case when number of values
358 //is more than $cfg['ForeignKeyMaxLimit']
359 $_url_params = array(
365 $dropdown = '<span class="curr_value">'
366 . htmlspecialchars($_REQUEST['curr_value'])
368 . '<a href="browse_foreigners.php'
369 . PMA_URL_getCommon($_url_params) . '"'
370 . ' target="_blank" class="browse_foreign" ' .'>'
371 . __('Browse foreign values')
374 $dropdown = PMA_foreignDropdown(
375 $foreignData['disp_row'],
376 $foreignData['foreign_field'],
377 $foreignData['foreign_display'],
379 $GLOBALS['cfg']['ForeignKeyMaxLimit']
381 $dropdown = '<select>' . $dropdown . '</select>';
388 * Get the HTML for the header of the page in print view if print view is selected.
389 * Otherwise returns null.
391 * @param string $db current database
392 * @param string $sql_query current sql query
393 * @param int $num_rows the number of rows in result
395 * @return string $header html for the header
397 function PMA_getHtmlForPrintViewHeader($db, $sql_query, $num_rows)
399 $response = PMA_Response
::getInstance();
400 $header = $response->getHeader();
401 if (isset($_REQUEST['printview']) && $_REQUEST['printview'] == '1') {
402 PMA_Util
::checkParameters(array('db', 'full_sql_query'));
403 $header->enablePrintView();
405 if ( $GLOBALS['cfg']['Server']['verbose']) {
406 $hostname = $GLOBALS['cfg']['Server']['verbose'];
408 $hostname = $GLOBALS['cfg']['Server']['host'];
409 if (! empty( $GLOBALS['cfg']['Server']['port'])) {
410 $hostname .= $GLOBALS['cfg']['Server']['port'];
414 $versions = "phpMyAdmin " . PMA_VERSION
;
415 $versions .= " / ";
416 $versions .= "MySQL " . PMA_MYSQL_STR_VERSION
;
418 $print_view_header = '';
419 $print_view_header .= "<h1>" . __('SQL result') . "</h1>";
420 $print_view_header .= "<p>";
421 $print_view_header .= "<strong>" . __('Host:')
422 . "</strong> $hostname<br />";
423 $print_view_header .= "<strong>" . __('Database:') . "</strong> "
424 . htmlspecialchars($db) . "<br />";
425 $print_view_header .= "<strong>" . __('Generation Time:') . "</strong> "
426 . PMA_Util
::localisedDate() . "<br />";
427 $print_view_header .= "<strong>" . __('Generated by:')
428 . "</strong> $versions<br />";
429 $print_view_header .= "<strong>" . __('SQL query:') . "</strong> "
430 . htmlspecialchars($sql_query) . ";";
431 if (isset($num_rows)) {
432 $print_view_header .= "<br />";
433 $print_view_header .= "<strong>" . __('Rows:') . "</strong> $num_rows";
435 $print_view_header .= "</p>";
437 $print_view_header = null;
440 return $print_view_header;
444 * Get the HTML for the profiling table and accompanying chart if profiling is set.
445 * Otherwise returns null
447 * @param string $url_query url query
448 * @param string $db current database
449 * @param array $profiling_results array containing the profiling info
451 * @return string $profiling_table html for the profiling table and chart
453 function PMA_getHtmlForProfilingChart($url_query, $db, $profiling_results)
455 if (isset($profiling_results)) {
456 $pma_token = $_SESSION[' PMA_token '];
457 $url_query = (isset($url_query) ?
$url_query : PMA_URL_getCommon($db));
459 $profiling_table = '';
460 $profiling_table .= '<fieldset><legend>' . __('Profiling')
461 . '</legend>' . "\n";
462 $profiling_table .= '<div style="float: left;">';
463 $profiling_table .= '<h3>' . __('Detailed profile') . '</h3>';
464 $profiling_table .= '<table id="profiletable"><thead>' . "\n";
465 $profiling_table .= ' <tr>' . "\n";
466 $profiling_table .= ' <th>' . __('Order')
467 . '<div class="sorticon"></div></th>' . "\n";
468 $profiling_table .= ' <th>' . __('State')
469 . PMA_Util
::showMySQLDocu('general-thread-states')
470 . '<div class="sorticon"></div></th>' . "\n";
471 $profiling_table .= ' <th>' . __('Time')
472 . '<div class="sorticon"></div></th>' . "\n";
473 $profiling_table .= ' </tr></thead><tbody>' . "\n";
474 list($detailed_table, $chart_json, $profiling_stats)
475 = PMA_analyzeAndGetTableHtmlForProfilingResults($profiling_results);
476 $profiling_table .= $detailed_table;
477 $profiling_table .= '</tbody></table>' . "\n";
478 $profiling_table .= '</div>';
480 $profiling_table .= '<div style="float: left; margin-left:10px;">';
481 $profiling_table .= '<h3>' . __('Summary by state') . '</h3>';
482 $profiling_table .= '<table id="profilesummarytable"><thead>' . "\n";
483 $profiling_table .= ' <tr>' . "\n";
484 $profiling_table .= ' <th>' . __('State')
485 . PMA_Util
::showMySQLDocu('general-thread-states')
486 . '<div class="sorticon"></div></th>' . "\n";
487 $profiling_table .= ' <th>' . __('Total Time')
488 . '<div class="sorticon"></div></th>' . "\n";
489 $profiling_table .= ' <th>' . __('% Time')
490 . '<div class="sorticon"></div></th>' . "\n";
491 $profiling_table .= ' <th>' . __('Calls')
492 . '<div class="sorticon"></div></th>' . "\n";
493 $profiling_table .= ' <th>' . __('ø Time')
494 . '<div class="sorticon"></div></th>' . "\n";
495 $profiling_table .= ' </tr></thead><tbody>' . "\n";
496 $profiling_table .= PMA_getTableHtmlForProfilingSummaryByState(
499 $profiling_table .= '</tbody></table>' . "\n";
501 $profiling_table .= <<<EOT
502 <script type="text/javascript">
503 pma_token = '$pma_token';
504 url_query = '$url_query';
507 $profiling_table .= "</div>";
509 //require_once 'libraries/chart.lib.php';
510 $profiling_table .= '<div id="profilingChartData" style="display:none;">';
511 $profiling_table .= json_encode($chart_json);
512 $profiling_table .= '</div>';
513 $profiling_table .= '<div id="profilingchart" style="display:none;">';
514 $profiling_table .= '</div>';
515 $profiling_table .= '<script type="text/javascript">';
516 $profiling_table .= 'makeProfilingChart();';
517 $profiling_table .= 'initProfilingTables();';
518 $profiling_table .= '</script>';
519 $profiling_table .= '</fieldset>' . "\n";
521 $profiling_table = null;
523 return $profiling_table;
527 * Function to get HTML for detailed profiling results table, profiling stats, and
528 * $chart_json for displaying the chart.
530 * @param array $profiling_results profiling results
534 function PMA_analyzeAndGetTableHtmlForProfilingResults(
537 $profiling_stats = array(
541 $chart_json = Array();
544 foreach ($profiling_results as $one_result) {
545 if (isset($profiling_stats['states'][ucwords($one_result['Status'])])) {
546 $states = $profiling_stats['states'];
547 $states[ucwords($one_result['Status'])]['time']
548 +
= $one_result['Duration'];
549 $states[ucwords($one_result['Status'])]['calls']++
;
551 $profiling_stats['states'][ucwords($one_result['Status'])] = array(
552 'total_time' => $one_result['Duration'],
556 $profiling_stats['total_time'] +
= $one_result['Duration'];
558 $table .= ' <tr>' . "\n";
559 $table .= '<td>' . $i++
. '</td>' . "\n";
560 $table .= '<td>' . ucwords($one_result['Status'])
562 $table .= '<td class="right">'
563 . (PMA_Util
::formatNumber($one_result['Duration'], 3, 1))
564 . 's<span style="display:none;" class="rawvalue">'
565 . $one_result['Duration'] . '</span></td>' . "\n";
566 if (isset($chart_json[ucwords($one_result['Status'])])) {
567 $chart_json[ucwords($one_result['Status'])]
568 +
= $one_result['Duration'];
570 $chart_json[ucwords($one_result['Status'])]
571 = $one_result['Duration'];
574 return array($table, $chart_json, $profiling_stats);
578 * Function to get HTML for summary by state table
580 * @param array $profiling_stats profiling stats
582 * @return string $table html for the table
584 function PMA_getTableHtmlForProfilingSummaryByState($profiling_stats)
587 foreach ($profiling_stats['states'] as $name => $stats) {
588 $table .= ' <tr>' . "\n";
589 $table .= '<td>' . $name . '</td>' . "\n";
590 $table .= '<td align="right">'
591 . PMA_Util
::formatNumber($stats['total_time'], 3, 1)
592 . 's<span style="display:none;" class="rawvalue">'
593 . $stats['total_time'] . '</span></td>' . "\n";
594 $table .= '<td align="right">'
595 . PMA_Util
::formatNumber(
596 100 * ($stats['total_time'] / $profiling_stats['total_time']),
600 $table .= '<td align="right">' . $stats['calls'] . '</td>'
602 $table .= '<td align="right">'
603 . PMA_Util
::formatNumber(
604 $stats['total_time'] / $stats['calls'], 3, 1
606 . 's<span style="display:none;" class="rawvalue">'
607 . number_format($stats['total_time'] / $stats['calls'], 8, '.', '')
608 . '</span></td>' . "\n";
609 $table .= ' </tr>' . "\n";
615 * Get the HTML for the enum column dropdown
616 * During grid edit, if we have a enum field, returns the html for the
619 * @param string $db current database
620 * @param string $table current table
621 * @param string $column current column
622 * @param string $curr_value currently selected value
624 * @return string $dropdown html for the dropdown
626 function PMA_getHtmlForEnumColumnDropdown($db, $table, $column, $curr_value)
628 $values = PMA_getValuesForColumn($db, $table, $column);
629 $dropdown = '<option value=""> </option>';
630 $dropdown .= PMA_getHtmlForOptionsList($values, array($curr_value));
631 $dropdown = '<select>' . $dropdown . '</select>';
636 * Get the HTML for the set column dropdown
637 * During grid edit, if we have a set field, returns the html for the
640 * @param string $db current database
641 * @param string $table current table
642 * @param string $column current column
643 * @param string $curr_value currently selected value
645 * @return string $dropdown html for the set column
647 function PMA_getHtmlForSetColumn($db, $table, $column, $curr_value)
649 $values = PMA_getValuesForColumn($db, $table, $column);
652 //converts characters of $curr_value to HTML entities
653 $converted_curr_value = htmlentities(
654 $curr_value, ENT_COMPAT
, "UTF-8"
657 $selected_values = explode(',', $converted_curr_value);
658 $dropdown .= PMA_getHtmlForOptionsList($values, $selected_values);
660 $select_size = (sizeof($values) > 10) ?
10 : sizeof($values);
661 $dropdown = '<select multiple="multiple" size="' . $select_size . '">'
662 . $dropdown . '</select>';
668 * Get all the values for a enum column or set column in a table
670 * @param string $db current database
671 * @param string $table current table
672 * @param string $column current column
674 * @return array $values array containing the value list for the column
676 function PMA_getValuesForColumn($db, $table, $column)
678 $field_info_query = $GLOBALS['dbi']->getColumnsSql($db, $table, $column);
680 $field_info_result = $GLOBALS['dbi']->fetchResult(
681 $field_info_query, null, null, null, PMA_DatabaseInterface
::QUERY_STORE
684 $values = PMA_Util
::parseEnumSetValues($field_info_result[0]['Type']);
690 * Get HTML for options list
692 * @param array $values set of values
693 * @param array $selected_values currently selected values
695 * @return string $options HTML for options list
697 function PMA_getHtmlForOptionsList($values, $selected_values)
700 foreach ($values as $value) {
701 $options .= '<option value="' . $value . '"';
702 if (in_array($value, $selected_values, true)) {
703 $options .= ' selected="selected" ';
705 $options .= '>' . $value . '</option>';
711 * Function to get html for bookmark support if bookmarks are enabled. Else will
714 * @param string $disp_mode display mode
715 * @param bool $cfgBookmark configuration setting for bookmarking
716 * @param string $sql_query sql query
717 * @param string $db current database
718 * @param string $table current table
719 * @param string $complete_query complete query
720 * @param string $bkm_user bookmarking user
722 * @return string $html
724 function PMA_getHtmlForBookmark($disp_mode, $cfgBookmark, $sql_query, $db, $table,
725 $complete_query, $bkm_user
727 if ($disp_mode[7] == '1'
728 && (! empty($cfgBookmark) && empty($_GET['id_bookmark']))
729 && ! empty($sql_query)
737 'sql_query' => $sql_query,
741 $bkm_sql_query = urlencode(
742 isset($complete_query) ?
$complete_query : $sql_query
744 $html = '<form action="sql.php" method="post"'
745 . ' onsubmit="return ! emptyFormElements(this,'
746 . '\'bkm_fields[bkm_label]\');"'
747 . ' id="bookmarkQueryForm">';
748 $html .= PMA_URL_getHiddenInputs();
749 $html .= '<input type="hidden" name="goto" value="' . $goto . '" />';
750 $html .= '<input type="hidden" name="bkm_fields[bkm_database]"'
751 . ' value="' . htmlspecialchars($db) . '" />';
752 $html .= '<input type="hidden" name="bkm_fields[bkm_user]"'
753 . ' value="' . $bkm_user . '" />';
754 $html .= '<input type="hidden" name="bkm_fields[bkm_sql_query]"'
758 $html .= '<fieldset>';
760 $html .= PMA_Util
::getIcon(
761 'b_bookmark.png', __('Bookmark this SQL query'), true
763 $html .= '</legend>';
764 $html .= '<div class="formelement">';
765 $html .= '<label for="fields_label_">' . __('Label:') . '</label>';
766 $html .= '<input type="text" id="fields_label_"'
767 . ' name="bkm_fields[bkm_label]" value="" />';
769 $html .= '<div class="formelement">';
770 $html .= '<input type="checkbox" name="bkm_all_users"'
771 . ' id="bkm_all_users" value="true" />';
772 $html .= '<label for="bkm_all_users">'
773 . __('Let every user access this bookmark')
776 $html .= '<div class="clearfloat"></div>';
777 $html .= '</fieldset>';
778 $html .= '<fieldset class="tblFooters">';
779 $html .= '<input type="hidden" name="store_bkm" value="1" />';
780 $html .= '<input type="submit"'
781 . ' value="' . __('Bookmark this SQL query') . '" />';
782 $html .= '</fieldset>';
793 * Function to check whether to remember the sorting order or not
795 * @param array $analyzed_sql_results the analyzed query and other varibles set
796 * after analyzing the query
800 function PMA_isRememberSortingOrder($analyzed_sql_results)
802 $select_from = isset(
803 $analyzed_sql_results['analyzed_sql'][0]['queryflags']['select_from']
805 if ($GLOBALS['cfg']['RememberSorting']
806 && ! ($analyzed_sql_results['is_count']
807 ||
$analyzed_sql_results['is_export']
808 ||
$analyzed_sql_results['is_func']
809 ||
$analyzed_sql_results['is_analyse'])
810 && isset($analyzed_sql_results['analyzed_sql'][0]['select_expr'])
811 && (count($analyzed_sql_results['analyzed_sql'][0]['select_expr']) == 0)
813 && count($analyzed_sql_results['analyzed_sql'][0]['table_ref']) == 1
822 * Function to check whether the LIMIT clause should be appended or not
824 * @param array $analyzed_sql_results the analyzed query and other varibles set
825 * after analyzing the query
829 function PMA_isAppendLimitClause($analyzed_sql_results)
831 $select_from = isset(
832 $analyzed_sql_results['analyzed_sql'][0]['queryflags']['select_from']
834 if (($_SESSION['tmp_user_values']['max_rows'] != 'all')
835 && ! ($analyzed_sql_results['is_count']
836 ||
$analyzed_sql_results['is_export']
837 ||
$analyzed_sql_results['is_func']
838 ||
$analyzed_sql_results['is_analyse'])
840 && ! isset($analyzed_sql_results['analyzed_sql'][0]['queryflags']['offset'])
841 && empty($analyzed_sql_results['analyzed_sql'][0]['limit_clause'])
850 * Function to check whether this query is for just browsing
852 * @param array $analyzed_sql_results the analyzed query and other varibles set
853 * after analyzing the query
854 * @param boolean $find_real_end whether the real end should be found
858 function PMA_isJustBrowsing($analyzed_sql_results, $find_real_end)
861 $analyzed_sql_results['analyzed_sql'][0]['queryflags']['distinct']
865 $analyzed_sql_results['analyzed_sql'][0]['table_ref'][1]['table_name']
867 if (! $analyzed_sql_results['is_group']
868 && ! isset($analyzed_sql_results['analyzed_sql'][0]['queryflags']['union'])
871 && (empty($analyzed_sql_results['analyzed_sql'][0]['where_clause'])
872 ||
$analyzed_sql_results['analyzed_sql'][0]['where_clause'] == '1 ')
873 && ! isset($find_real_end)
882 * Function to check whether the reated transformation information shoul be deleted
884 * @param array $analyzed_sql_results the analyzed query and other varibles set
885 * after analyzing the query
889 function PMA_isDeleteTransformationInfo($analyzed_sql_results)
891 if (!empty($analyzed_sql_results['analyzed_sql'][0]['querytype'])
892 && (($analyzed_sql_results['analyzed_sql'][0]['querytype'] == 'ALTER')
893 ||
($analyzed_sql_results['analyzed_sql'][0]['querytype'] == 'DROP'))
902 * Function to check whether the user has rights to drop the database
904 * @param array $analyzed_sql_results the analyzed query and other varibles set
905 * after analyzing the query
906 * @param boolean $allowUserDropDatabase whether the user is allowed to drop db
907 * @param boolean $is_superuser whether this user is a superuser
911 function PMA_hasNoRightsToDropDatabase($analyzed_sql_results,
912 $allowUserDropDatabase, $is_superuser
914 if (! defined('PMA_CHK_DROP')
915 && ! $allowUserDropDatabase
916 && isset ($analyzed_sql_results['drop_database'])
917 && $analyzed_sql_results['drop_database'] == 1
927 * Function to set the column order
929 * @param PMA_Table $pmatable PMA_Table instance
931 * @return boolean $retval
933 function PMA_setColumnOrder($pmatable)
935 $col_order = explode(',', $_REQUEST['col_order']);
936 $retval = $pmatable->setUiProp(
937 PMA_Table
::PROP_COLUMN_ORDER
,
939 $_REQUEST['table_create_time']
941 if (gettype($retval) != 'boolean') {
942 $response = PMA_Response
::getInstance();
943 $response->isSuccess(false);
944 $response->addJSON('message', $retval->getString());
952 * Function to set the column visibility
954 * @param PMA_Table $pmatable PMA_Table instance
956 * @return boolean $retval
958 function PMA_setColumnVisibility($pmatable)
960 $col_visib = explode(',', $_REQUEST['col_visib']);
961 $retval = $pmatable->setUiProp(
962 PMA_Table
::PROP_COLUMN_VISIB
, $col_visib,
963 $_REQUEST['table_create_time']
965 if (gettype($retval) != 'boolean') {
966 $response = PMA_Response
::getInstance();
967 $response->isSuccess(false);
968 $response->addJSON('message', $retval->getString());
975 * Function to check the request for setting the column order or visibility
977 * @param String $table the current table
978 * @param String $db the current database
982 function PMA_setColumnOrderOrVisibility($table, $db)
984 $pmatable = new PMA_Table($table, $db);
988 if (isset($_REQUEST['col_order'])) {
989 $retval = PMA_setColumnOrder($pmatable);
992 // set column visibility
993 if ($retval === true && isset($_REQUEST['col_visib'])) {
994 $retval = PMA_setColumnVisibility($pmatable);
997 $response = PMA_Response
::getInstance();
998 $response->isSuccess($retval == true);
1003 * Function to add a bookmark
1005 * @param String $pmaAbsoluteUri absolute URI
1006 * @param String $goto goto page URL
1010 function PMA_addBookmark($pmaAbsoluteUri, $goto)
1012 $result = PMA_Bookmark_save(
1013 $_POST['bkm_fields'],
1014 (isset($_POST['bkm_all_users'])
1015 && $_POST['bkm_all_users'] == 'true' ?
true : false
1018 $response = PMA_Response
::getInstance();
1019 if ($response->isAjax()) {
1021 $msg = PMA_message
::success(__('Bookmark %s created'));
1022 $msg->addParam($_POST['bkm_fields']['bkm_label']);
1023 $response->addJSON('message', $msg);
1025 $msg = PMA_message
::error(__('Bookmark not created'));
1026 $response->isSuccess(false);
1027 $response->addJSON('message', $msg);
1031 // go back to sql.php to redisplay query; do not use & in this case:
1033 * @todo In which scenario does this happen?
1035 PMA_sendHeaderLocation(
1036 $pmaAbsoluteUri . $goto
1037 . '&label=' . $_POST['bkm_fields']['bkm_label']
1043 * Function to find the real end of rows
1045 * @param String $db the current database
1046 * @param String $table the current table
1048 * @return mixed the number of rows if "retain" param is true, otherwise true
1050 function PMA_findRealEndOfRows($db, $table)
1052 $unlim_num_rows = PMA_Table
::countRecords($db, $table, true);
1053 $_SESSION['tmp_user_values']['pos'] = @((ceil(
1054 $unlim_num_rows / $_SESSION['tmp_user_values']['max_rows']
1055 ) - 1) * $_SESSION['tmp_user_values']['max_rows']);
1057 return $unlim_num_rows;
1061 * Function to get values for the relational columns
1063 * @param String $db the current database
1064 * @param String $table the current table
1065 * @param String $display_field display field
1069 function PMA_getRelationalValues($db, $table, $display_field)
1071 $column = $_REQUEST['column'];
1072 if ($_SESSION['tmp_user_values']['relational_display'] == 'D'
1073 && isset($display_field)
1074 && strlen($display_field)
1075 && isset($_REQUEST['relation_key_or_display_column'])
1076 && $_REQUEST['relation_key_or_display_column']
1078 $curr_value = $_REQUEST['relation_key_or_display_column'];
1080 $curr_value = $_REQUEST['curr_value'];
1082 $dropdown = PMA_getHtmlForRelationalColumnDropdown(
1083 $db, $table, $column, $curr_value
1085 $response = PMA_Response
::getInstance();
1086 $response->addJSON('dropdown', $dropdown);
1091 * Function to get values for Enum or Set Columns
1093 * @param String $db the current database
1094 * @param String $table the current table
1095 * @param String $columnType whether enum or set
1099 function PMA_getEnumOrSetValues($db, $table, $columnType)
1101 $column = $_REQUEST['column'];
1102 $curr_value = $_REQUEST['curr_value'];
1103 $response = PMA_Response
::getInstance();
1104 if ($columnType == "enum") {
1105 $dropdown = PMA_getHtmlForEnumColumnDropdown(
1106 $db, $table, $column, $curr_value
1108 $response->addJSON('dropdown', $dropdown);
1110 $select = PMA_getHtmlForSetColumn($db, $table, $column, $curr_value);
1111 $response->addJSON('select', $select);
1117 * Function to append the limit clause
1119 * @param String $full_sql_query full sql query
1120 * @param array $analyzed_sql analyzed sql query
1121 * @param String $display_query display query
1125 function PMA_appendLimitClause($full_sql_query, $analyzed_sql, $display_query)
1127 $sql_limit_to_append = ' LIMIT ' . $_SESSION['tmp_user_values']['pos']
1128 . ', ' . $_SESSION['tmp_user_values']['max_rows'] . " ";
1129 $full_sql_query = PMA_getSqlWithLimitClause(
1132 $sql_limit_to_append
1136 * @todo pretty printing of this modified query
1138 if ($display_query) {
1139 // if the analysis of the original query revealed that we found
1140 // a section_after_limit, we now have to analyze $display_query
1141 // to display it correctly
1143 if (! empty($analyzed_sql[0]['section_after_limit'])
1144 && trim($analyzed_sql[0]['section_after_limit']) != ';'
1146 $analyzed_display_query = PMA_SQP_analyze(
1147 PMA_SQP_parse($display_query)
1149 $display_query = $analyzed_display_query[0]['section_before_limit']
1150 . "\n" . $sql_limit_to_append
1151 . $analyzed_display_query[0]['section_after_limit'];
1155 return array($sql_limit_to_append, $full_sql_query, isset(
1156 $analyzed_display_query)
1157 ?
$analyzed_display_query : null,
1158 isset($display_query) ?
$display_query : null
1163 * Function to get the default sql query for browsing page
1165 * @param String $db the current database
1166 * @param String $table the current table
1168 * @return String $sql_query the default $sql_query for browse page
1170 function PMA_getDefaultSqlQueryForBrowse($db, $table)
1172 include_once 'libraries/bookmark.lib.php';
1173 $book_sql_query = PMA_Bookmark_get(
1175 '\'' . PMA_Util
::sqlAddSlashes($table) . '\'',
1181 if (! empty($book_sql_query)) {
1182 $GLOBALS['using_bookmark_message'] = PMA_message
::notice(
1183 __('Using bookmark "%s" as default browse query.')
1185 $GLOBALS['using_bookmark_message']->addParam($table);
1186 $GLOBALS['using_bookmark_message']->addMessage(
1187 PMA_Util
::showDocu('faq', 'faq6-22')
1189 $sql_query = $book_sql_query;
1191 $sql_query = 'SELECT * FROM ' . PMA_Util
::backquote($table);
1193 unset($book_sql_query);
1199 * Responds an error when an error happens when executing the query
1201 * @param boolean $is_gotofile whether goto file or not
1202 * @param String $error error after executing the query
1203 * @param String $full_sql_query full sql query
1207 function PMA_handleQueryExecuteError($is_gotofile, $error, $full_sql_query)
1210 $message = PMA_Message
::rawError($error);
1211 $response = PMA_Response
::getInstance();
1212 $response->isSuccess(false);
1213 $response->addJSON('message', $message);
1215 PMA_Util
::mysqlDie($error, $full_sql_query, '', '');
1221 * Function to store the query as a bookmark
1223 * @param String $db the current database
1224 * @param String $bkm_user the bookmarking user
1225 * @param String $import_text import text
1226 * @param String $bkm_label bookmark label
1227 * @param boolean $bkm_replace whether to replace existing bookmarks
1231 function PMA_storeTheQueryAsBookmark($db, $bkm_user, $import_text,
1232 $bkm_label, $bkm_replace
1234 include_once 'libraries/bookmark.lib.php';
1236 'bkm_database' => $db,
1237 'bkm_user' => $bkm_user,
1238 'bkm_sql_query' => urlencode($import_text),
1239 'bkm_label' => $bkm_label
1242 // Should we replace bookmark?
1243 if (isset($bkm_replace)) {
1244 $bookmarks = PMA_Bookmark_getList($db);
1245 foreach ($bookmarks as $key => $val) {
1246 if ($val == $bkm_label) {
1247 PMA_Bookmark_delete($db, $key);
1252 PMA_Bookmark_save($bfields, isset($_POST['bkm_all_users']));
1257 * Function to execute the SQL query and set the execution time
1259 * @param String $full_sql_query the full sql query
1261 * @return mixed $result the results after running the query
1263 function PMA_executeQueryAndStoreResults($full_sql_query)
1265 // Measure query time.
1266 $querytime_before = array_sum(explode(' ', microtime()));
1268 $result = @$GLOBALS['dbi']->tryQuery(
1269 $full_sql_query, null, PMA_DatabaseInterface
::QUERY_STORE
1271 $querytime_after = array_sum(explode(' ', microtime()));
1273 $GLOBALS['querytime'] = $querytime_after - $querytime_before;
1275 // If a stored procedure was called, there may be more results that are
1276 // queued up and waiting to be flushed from the buffer. So let's do that.
1278 $GLOBALS['dbi']->storeResult();
1279 if (! $GLOBALS['dbi']->moreResults()) {
1282 } while ($GLOBALS['dbi']->nextResult());
1288 * Function to get the affected or changed number of rows after executing a query
1290 * @param boolean $is_affected whether the query affected a table
1291 * @param mixed $result results of executing the query
1292 * @param int $num_rows number of rows affected or changed
1294 * @return int $num_rows number of rows affected or changed
1296 function PMA_getNumberOfRowsAffectedOrChanged($is_affected, $result, $num_rows)
1298 if (! $is_affected) {
1299 $num_rows = ($result) ?
@$GLOBALS['dbi']->numRows($result) : 0;
1300 } elseif (! isset($num_rows)) {
1301 $num_rows = @$GLOBALS['dbi']->affectedRows();
1308 * Checks if the current database has changed
1309 * This could happen if the user sends a query like "USE `database`;"
1311 * @param String $db the database in the query
1313 * @return int $reload whether to reload the navigation(1) or not(0)
1315 function PMA_hasCurrentDbChanged($db)
1317 // Checks if the current database has changed
1318 // This could happen if the user sends a query like "USE `database`;"
1321 $current_db = $GLOBALS['dbi']->fetchValue('SELECT DATABASE()');
1322 if ($db !== $current_db) {
1325 $GLOBALS['dbi']->selectDb($db);
1332 * If a table, database or column gets dropped, clean comments.
1334 * @param String $db current database
1335 * @param String $table current table
1336 * @param String $dropped_column dropped column if any
1337 * @param bool $purge whether purge set or not
1338 * @param array $extra_data extra data
1340 * @return array $extra_data
1342 function PMA_cleanupRelations($db, $table, $dropped_column, $purge, $extra_data)
1344 include_once 'libraries/relation_cleanup.lib.php';
1346 if (isset($purge) && $purge == 1) {
1347 if (strlen($table) && strlen($db)) {
1348 PMA_relationsCleanupTable($db, $table);
1349 } elseif (strlen($db)) {
1350 PMA_relationsCleanupDatabase($db);
1354 if (isset($dropped_column)
1355 && !empty($dropped_column)
1359 PMA_relationsCleanupColumn($db, $table, $dropped_column);
1360 if (isset($extra_data)) {
1361 // to refresh the list of indexes (Ajax mode)
1362 $extra_data['indexes_list'] = PMA_Index
::getView($table, $db);
1370 * Function to count the total number of rows for the same 'SELECT' query without
1371 * the 'LIMIT' clause that may have been programatically added
1373 * @param int $num_rows number of rows affected/changed by the query
1374 * @param bool $is_select whether the query is SELECT or not
1375 * @param bool $justBrowsing whether just browsing or not
1376 * @param string $db the current database
1377 * @param string $table the current table
1378 * @param array $parsed_sql parsed sql
1379 * @param array $analyzed_sql_results the analyzed query and other varibles set
1380 * after analyzing the query
1382 * @return int $unlim_num_rows unlimited number of rows
1384 function PMA_countQueryResults(
1385 $num_rows, $is_select, $justBrowsing,
1386 $db, $table, $parsed_sql, $analyzed_sql_results
1388 if (!PMA_isAppendLimitClause($analyzed_sql_results)) {
1389 // if we did not append a limit, set this to get a correct
1390 // "Showing rows..." message
1391 // $_SESSION['tmp_user_values']['max_rows'] = 'all';
1392 $unlim_num_rows = $num_rows;
1393 } elseif ($is_select) {
1394 // c o u n t q u e r y
1396 // If we are "just browsing", there is only one table,
1397 // and no WHERE clause (or just 'WHERE 1 '),
1398 // we do a quick count (which uses MaxExactCount) because
1399 // SQL_CALC_FOUND_ROWS is not quick on large InnoDB tables
1401 // However, do not count again if we did it previously
1402 // due to $find_real_end == true
1403 if ($justBrowsing) {
1404 $unlim_num_rows = PMA_Table
::countRecords(
1411 // add select expression after the SQL_CALC_FOUND_ROWS
1413 // for UNION, just adding SQL_CALC_FOUND_ROWS
1414 // after the first SELECT works.
1416 // take the left part, could be:
1420 $analyzed_sql = $analyzed_sql_results['analyzed_sql'];
1422 $count_query = PMA_SQP_format(
1426 $analyzed_sql[0]['position_of_first_select'] +
1
1428 $count_query .= ' SQL_CALC_FOUND_ROWS ';
1429 // add everything that was after the first SELECT
1430 $count_query .= PMA_SQP_format(
1433 $analyzed_sql[0]['position_of_first_select'] +
1
1435 // ensure there is no semicolon at the end of the
1436 // count query because we'll probably add
1437 // a LIMIT 1 clause after it
1438 $count_query = rtrim($count_query);
1439 $count_query = rtrim($count_query, ';');
1441 // if using SQL_CALC_FOUND_ROWS, add a LIMIT to avoid
1442 // long delays. Returned count will be complete anyway.
1443 // (but a LIMIT would disrupt results in an UNION)
1445 if (! isset($analyzed_sql[0]['queryflags']['union'])) {
1446 $count_query .= ' LIMIT 1';
1449 // run the count query
1451 $GLOBALS['dbi']->tryQuery($count_query);
1452 // if (mysql_error()) {
1455 // (SELECT `User`, `Host`, `Db`, `Select_priv` FROM `db`)
1456 // UNION (SELECT `User`, `Host`, "%" AS "Db",
1458 // FROM `user`) ORDER BY `User`, `Host`, `Db`;
1459 // and although the generated count_query is wrong
1460 // the SELECT FOUND_ROWS() work! (maybe it gets the
1461 // count from the latest query that worked)
1463 // another case where the count_query is wrong:
1464 // SELECT COUNT(*), f1 from t1 group by f1
1465 // and you click to sort on count(*)
1467 $unlim_num_rows = $GLOBALS['dbi']->fetchValue('SELECT FOUND_ROWS()');
1468 } // end else "just browsing"
1469 } else {// not $is_select
1470 $unlim_num_rows = 0;
1473 return $unlim_num_rows;
1477 * Function to handle all aspects relating to executing the query
1479 * @param array $analyzed_sql_results analyzed sql results
1480 * @param String $full_sql_query full sql query
1481 * @param boolean $is_gotofile whether to go to a file
1482 * @param String $db current database
1483 * @param String $table current table
1484 * @param boolean $find_real_end whether to find the real end
1485 * @param String $import_text sql command
1486 * @param array $extra_data extra data
1490 function PMA_executeTheQuery($analyzed_sql_results, $full_sql_query, $is_gotofile,
1491 $db, $table, $find_real_end, $import_text, $extra_data
1493 // Only if we ask to see the php code
1494 if (isset($GLOBALS['show_as_php']) ||
! empty($GLOBALS['validatequery'])) {
1497 $unlim_num_rows = 0;
1498 } else { // If we don't ask to see the php code
1499 if (isset($_SESSION['profiling']) && PMA_Util
::profilingSupported()) {
1500 $GLOBALS['dbi']->query('SET PROFILING=1;');
1503 $result = PMA_executeQueryAndStoreResults($full_sql_query);
1505 // Displays an error message if required and stop parsing the script
1506 $error = $GLOBALS['dbi']->getError();
1508 PMA_handleQueryExecuteError($is_gotofile, $error, $full_sql_query);
1511 // If there are no errors and bookmarklabel was given,
1512 // store the query as a bookmark
1513 if (! empty($_POST['bkm_label']) && ! empty($import_text)) {
1514 PMA_storeTheQueryAsBookmark(
1515 $db, $GLOBALS['cfg']['Bookmark']['user'],
1516 $import_text, $_POST['bkm_label'],
1517 isset($_POST['bkm_replace']) ?
$_POST['bkm_replace'] : null
1519 } // end store bookmarks
1521 // Gets the number of rows affected/returned
1522 // (This must be done immediately after the query because
1523 // mysql_affected_rows() reports about the last query done)
1524 $num_rows = PMA_getNumberOfRowsAffectedOrChanged(
1525 $analyzed_sql_results['is_affected'], $result,
1526 isset($num_rows) ?
$num_rows : null
1529 // Grabs the profiling results
1530 if (isset($_SESSION['profiling']) && PMA_Util
::profilingSupported()) {
1531 $profiling_results = $GLOBALS['dbi']->fetchResult('SHOW PROFILE;');
1534 $justBrowsing = PMA_isJustBrowsing(
1535 $analyzed_sql_results, isset($find_real_end) ?
$find_real_end : null
1538 $unlim_num_rows = PMA_countQueryResults(
1539 $num_rows, $analyzed_sql_results['is_select'], $justBrowsing, $db,
1540 $table, $analyzed_sql_results['parsed_sql'], $analyzed_sql_results
1543 $extra_data = PMA_cleanupRelations(
1544 isset($db) ?
$db : '', isset($table) ?
$table : '',
1545 isset($_REQUEST['dropped_column']) ?
$_REQUEST['dropped_column'] : null,
1546 isset($_REQUEST['purge']) ?
$_REQUEST['purge'] : null,
1547 isset($extra_data) ?
$extra_data : null
1551 return array($result, $num_rows, $unlim_num_rows,
1552 isset($profiling_results) ?
$profiling_results : null,
1553 isset($justBrowsing) ?
$justBrowsing : null, $extra_data
1557 * Delete related tranformatioinformationn information
1559 * @param String $db current database
1560 * @param String $table current table
1561 * @param array $analyzed_sql analyzed sql query
1565 function PMA_deleteTransformationInfo($db, $table, $analyzed_sql)
1567 include_once 'libraries/transformations.lib.php';
1568 if ($analyzed_sql[0]['querytype'] == 'ALTER') {
1569 if (stripos($analyzed_sql[0]['unsorted_query'], 'DROP') !== false) {
1570 $drop_column = PMA_getColumnNameInColumnDropSql(
1571 $analyzed_sql[0]['unsorted_query']
1574 if ($drop_column != '') {
1575 PMA_clearTransformations($db, $table, $drop_column);
1579 } else if (($analyzed_sql[0]['querytype'] == 'DROP') && ($table != '')) {
1580 PMA_clearTransformations($db, $table);
1585 * Function to get the message for the no rows returned case
1587 * @param string $message_to_show message to show
1588 * @param array $analyzed_sql_results analyzed sql results
1589 * @param int $num_rows number of rows
1591 * @return string $message
1593 function PMA_getMessageForNoRowsReturned($message_to_show, $analyzed_sql_results,
1596 if ($analyzed_sql_results['is_delete']) {
1597 $message = PMA_Message
::getMessageForDeletedRows($num_rows);
1598 } elseif ($analyzed_sql_results['is_insert']) {
1599 if ($analyzed_sql_results['is_replace']) {
1600 // For replace we get DELETED + INSERTED row count,
1601 // so we have to call it affected
1602 $message = PMA_Message
::getMessageForAffectedRows($num_rows);
1604 $message = PMA_Message
::getMessageForInsertedRows($num_rows);
1606 $insert_id = $GLOBALS['dbi']->insertId();
1607 if ($insert_id != 0) {
1608 // insert_id is id of FIRST record inserted in one insert,
1609 // so if we inserted multiple rows, we had to increment this
1610 $message->addMessage('[br]');
1611 // need to use a temporary because the Message class
1612 // currently supports adding parameters only to the first
1614 $_inserted = PMA_Message
::notice(__('Inserted row id: %1$d'));
1615 $_inserted->addParam($insert_id +
$num_rows - 1);
1616 $message->addMessage($_inserted);
1618 } elseif ($analyzed_sql_results['is_affected']) {
1619 $message = PMA_Message
::getMessageForAffectedRows($num_rows);
1621 // Ok, here is an explanation for the !$is_select.
1622 // The form generated by sql_query_form.lib.php
1623 // and db_sql.php has many submit buttons
1624 // on the same form, and some confusion arises from the
1625 // fact that $message_to_show is sent for every case.
1626 // The $message_to_show containing a success message and sent with
1627 // the form should not have priority over errors
1628 } elseif (! empty($message_to_show) && ! $analyzed_sql_results['is_select']) {
1629 $message = PMA_Message
::rawSuccess(htmlspecialchars($message_to_show));
1630 } elseif (! empty($GLOBALS['show_as_php'])) {
1631 $message = PMA_Message
::success(__('Showing as PHP code'));
1632 } elseif (isset($GLOBALS['show_as_php'])) {
1633 /* User disable showing as PHP, query is only displayed */
1634 $message = PMA_Message
::notice(__('Showing SQL query'));
1635 } elseif (! empty($GLOBALS['validatequery'])) {
1636 $message = PMA_Message
::notice(__('Validated SQL'));
1638 $message = PMA_Message
::success(
1639 __('MySQL returned an empty result set (i.e. zero rows).')
1643 if (isset($GLOBALS['querytime'])) {
1644 $_querytime = PMA_Message
::notice('(' . __('Query took %01.4f sec') . ')');
1645 $_querytime->addParam($GLOBALS['querytime']);
1646 $message->addMessage($_querytime);
1653 * Function to send the Ajax response when no rows returned
1655 * @param string $message message to be send
1656 * @param array $analyzed_sql analyzed sql
1657 * @param object $displayResultsObject DisplayResult instance
1658 * @param array $extra_data extra data
1662 function PMA_sendAjaxResponseForNoResultsReturned($message, $analyzed_sql,
1663 $displayResultsObject, $extra_data
1666 * @todo find a better way to make getMessage() in Header.class.php
1667 * output the intended message
1669 $GLOBALS['message'] = $message;
1671 if ($GLOBALS['cfg']['ShowSQL']) {
1672 $extra_data['sql_query'] = PMA_Util
::getMessage(
1673 $message, $GLOBALS['sql_query'], 'success'
1676 if (isset($GLOBALS['reload']) && $GLOBALS['reload'] == 1) {
1677 $extra_data['reload'] = 1;
1678 $extra_data['db'] = $GLOBALS['db'];
1680 $response = PMA_Response
::getInstance();
1681 $response->isSuccess($message->isSuccess());
1682 // No need to manually send the message
1683 // The Response class will handle that automatically
1684 $query__type = PMA_DisplayResults
::QUERY_TYPE_SELECT
;
1685 if ($analyzed_sql[0]['querytype'] == $query__type) {
1686 $createViewHTML = $displayResultsObject->getCreateViewQueryResultOp(
1689 $response->addHTML($createViewHTML.'<br />');
1692 $response->addJSON(isset($extra_data) ?
$extra_data : array());
1693 if (empty($_REQUEST['ajax_page_request'])) {
1694 $response->addJSON('message', $message);
1700 * Function to respond back when the query returns zero rows
1701 * This method is called
1702 * 1-> When browsing an empty table
1703 * 2-> When executing a query on a non empty table which returns zero results
1704 * 3-> When executing a query on an empty table
1705 * 4-> When executing an INSERT, UPDATE, DEDETE query from the SQL tab
1706 * 5-> When deleting a row from BROWSE tab
1707 * 6-> When searching using the SEARCH tab which returns zero results
1708 * 7-> When changing the structure of the table except change operation
1710 * @param array $analyzed_sql_results analyzed sql results
1711 * @param string $db current database
1712 * @param string $table current table
1713 * @param string $message_to_show message to show
1714 * @param int $num_rows number of rows
1715 * @param object $displayResultsObject DisplayResult instance
1716 * @param array $extra_data extra data
1720 function PMA_sendQueryResponseForNoResultsReturned($analyzed_sql_results, $db,
1721 $table, $message_to_show, $num_rows, $displayResultsObject, $extra_data
1723 if (PMA_isDeleteTransformationInfo($analyzed_sql_results)) {
1724 PMA_deleteTransformationInfo(
1725 $db, $table, $analyzed_sql_results['analyzed_sql']
1729 $message = PMA_getMessageForNoRowsReturned(
1730 isset($message_to_show) ?
$message_to_show : null, $analyzed_sql_results,
1733 if ($GLOBALS['is_ajax_request'] == true && !isset($GLOBALS['show_as_php'])) {
1734 PMA_sendAjaxResponseForNoResultsReturned(
1735 $message, $analyzed_sql_results['analyzed_sql'],
1736 $displayResultsObject,
1737 isset($extra_data) ?
$extra_data : null
1744 * Function to send response for ajax grid edit
1746 * @param object $result result of the executed query
1750 function PMA_sendResponseForGridEdit($result)
1752 $row = $GLOBALS['dbi']->fetchRow($result);
1753 $response = PMA_Response
::getInstance();
1754 $response->addJSON('value', $row[0]);
1759 * Function to get html for the sql query results div
1761 * @param string $previous_update_query_html html for the previously executed query
1762 * @param string $profiling_chart_html html for profiling
1763 * @param object $missing_unique_column_msg message for the missing unique column
1764 * @param object $bookmark_created_msg message for bookmark creation
1765 * @param string $table_html html for the table for displaying sql
1767 * @param string $indexes_problems_html html for displaying errors in indexes
1768 * @param string $bookmark_support_html html for displaying bookmark form
1769 * @param string $print_button_html html for the print button in printview
1771 * @return string $html_output
1773 function PMA_getHtmlForSqlQueryResults($previous_update_query_html,
1774 $profiling_chart_html, $missing_unique_column_msg, $bookmark_created_msg,
1775 $table_html, $indexes_problems_html, $bookmark_support_html, $print_button_html
1777 //begin the sqlqueryresults div here. container div
1778 $html_output = '<div id="sqlqueryresults" class="ajax">';
1779 $html_output .= isset($previous_update_query_html)
1780 ?
$previous_update_query_html : '';
1781 $html_output .= isset($profiling_chart_html) ?
$profiling_chart_html : '';
1782 $html_output .= isset($missing_unique_column_msg)
1783 ?
$missing_unique_column_msg->getDisplay() : '';
1784 $html_output .= isset($bookmark_created_msg)
1785 ?
$bookmark_created_msg->getDisplay() : '';
1786 $html_output .= $table_html;
1787 $html_output .= isset($indexes_problems_html) ?
$indexes_problems_html : '';
1788 $html_output .= isset($bookmark_support_html) ?
$bookmark_support_html : '';
1789 $html_output .= isset($print_button_html) ?
$print_button_html : '';
1790 $html_output .= '</div>'; // end sqlqueryresults div
1792 return $html_output;
1796 * Returns a message for successful creation of a bookmark or null if a bookmark
1799 * @return object $bookmark_created_msg
1801 function PMA_getBookmarkCreatedMessage()
1803 if (isset($_GET['label'])) {
1804 $bookmark_created_msg = PMA_message
::success(__('Bookmark %s created'));
1805 $bookmark_created_msg->addParam($_GET['label']);
1807 $bookmark_created_msg = null;
1810 return $bookmark_created_msg;
1814 * Function to get html for the sql query results table
1816 * @param array $sql_data sql data
1817 * @param object $displayResultsObject instance of DisplayResult.class
1818 * @param string $db current database
1819 * @param string $goto goto page url
1820 * @param string $pmaThemeImage theme image uri
1821 * @param string $url_query url query
1822 * @param string $disp_mode display mode
1823 * @param string $sql_limit_to_append sql limit to append
1824 * @param bool $editable whether the result table is editable or not
1825 * @param int $unlim_num_rows unlimited number of rows
1826 * @param int $num_rows number of rows
1827 * @param bool $showtable whether to show table or not
1828 * @param object $result result of the executed query
1829 * @param array $analyzed_sql_results analyzed sql results
1833 function PMA_getHtmlForSqlQueryResultsTable($sql_data, $displayResultsObject, $db,
1834 $goto, $pmaThemeImage, $url_query, $disp_mode, $sql_limit_to_append,
1835 $editable, $unlim_num_rows, $num_rows, $showtable, $result,
1836 $analyzed_sql_results
1838 $printview = isset($_REQUEST['printview']) ?
$_REQUEST['printview'] : null;
1839 if (! empty($sql_data) && ($sql_data['valid_queries'] > 1)
1840 ||
$analyzed_sql_results['is_procedure']
1842 $_SESSION['is_multi_query'] = true;
1843 $table_html = PMA_getTableHtmlForMultipleQueries(
1844 $displayResultsObject, $db, $sql_data, $goto,
1845 $pmaThemeImage, $printview, $url_query,
1846 $disp_mode, $sql_limit_to_append, $editable
1849 if (isset($result) && $result) {
1850 $fields_meta = $GLOBALS['dbi']->getFieldsMeta($result);
1851 $fields_cnt = count($fields_meta);
1853 $_SESSION['is_multi_query'] = false;
1854 $displayResultsObject->setProperties(
1855 $unlim_num_rows, $fields_meta, $analyzed_sql_results['is_count'],
1856 $analyzed_sql_results['is_export'], $analyzed_sql_results['is_func'],
1857 $analyzed_sql_results['is_analyse'], $num_rows,
1858 $fields_cnt, $GLOBALS['querytime'], $pmaThemeImage, $GLOBALS['text_dir'],
1859 $analyzed_sql_results['is_maint'], $analyzed_sql_results['is_explain'],
1860 $analyzed_sql_results['is_show'], $showtable, $printview, $url_query,
1864 $table_html = $displayResultsObject->getTable(
1865 $result, $disp_mode, $analyzed_sql_results['analyzed_sql']
1867 $GLOBALS['dbi']->freeResult($result);
1874 * Function to get html for the previous query if there is such. If not will return
1877 * @param string $disp_query display query
1878 * @param bool $showSql whether to show sql
1879 * @param array $sql_data sql data
1880 * @param string $disp_message display message
1882 * @return string $previous_update_query_html
1884 function PMA_getHtmlForPreviousUpdateQuery($disp_query, $showSql, $sql_data,
1887 // previous update query (from tbl_replace)
1888 if (isset($disp_query) && ($showSql == true) && empty($sql_data)) {
1889 $previous_update_query_html = PMA_Util
::getMessage(
1890 $disp_message, $disp_query, 'success'
1893 $previous_update_query_html = null;
1896 return $previous_update_query_html;
1900 * To get the message if a column index is missing. If not will return null
1902 * @param string $table current table
1903 * @param string $db current database
1904 * @param boolean $editable whether the results table can be editable or not
1905 * @param string $disp_mode display mode
1907 * @return object $message
1909 function PMA_getMessageIfMissingColumnIndex($table, $db, $editable, $disp_mode)
1911 if (!empty($table) && ($GLOBALS['dbi']->isSystemSchema($db) ||
!$editable)) {
1912 $missing_unique_column_msg = PMA_message
::notice(
1914 'Current selection does not contain a unique column.'
1915 . ' Grid edit, checkbox, Edit, Copy and Delete features'
1916 . ' are not available.'
1920 $missing_unique_column_msg = null;
1923 return $missing_unique_column_msg;
1927 * Function to get html to display problems in indexes
1929 * @param string $query_type query type
1930 * @param bool $selected whether check table, optimize table, analyze
1931 * table or repair table has been selected with
1932 * respect to the selected tables from the
1933 * database structure page.
1934 * @param string $db current database
1938 function PMA_getHtmlForIndexesProblems($query_type, $selected, $db)
1940 // BEGIN INDEX CHECK See if indexes should be checked.
1941 if (isset($query_type)
1942 && $query_type == 'check_tbl'
1944 && is_array($selected)
1946 $indexes_problems_html = '';
1947 foreach ($selected as $idx => $tbl_name) {
1948 $check = PMA_Index
::findDuplicates($tbl_name, $db);
1949 if (! empty($check)) {
1950 $indexes_problems_html .= sprintf(
1951 __('Problems with indexes of table `%s`'), $tbl_name
1953 $indexes_problems_html .= $check;
1957 $indexes_problems_html = null;
1960 return $indexes_problems_html;
1964 * Function to get the html for the print button in printview
1966 * @return string $print_button_html html for the print button
1968 function PMA_getHtmlForPrintButton()
1970 // Do print the page if required
1971 if (isset($_REQUEST['printview']) && $_REQUEST['printview'] == '1') {
1972 $print_button_html = PMA_Util
::getButton();
1974 $print_button_html = null;
1977 return $print_button_html;
1981 * Function to display results when the executed query returns non empty results
1983 * @param array $result executed query results
1984 * @param bool $justBrowsing whether just browsing or not
1985 * @param array $analyzed_sql_results analysed sql results
1986 * @param string $db current database
1987 * @param string $table current table
1988 * @param string $disp_mode display mode
1989 * @param string $message message to show
1990 * @param array $sql_data sql data
1991 * @param object $displayResultsObject Instance of DisplyResults.class
1992 * @param string $goto goto page url
1993 * @param string $pmaThemeImage uri of the theme image
1994 * @param string $sql_limit_to_append sql limit to append
1995 * @param int $unlim_num_rows unlimited number of rows
1996 * @param int $num_rows number of rows
1997 * @param string $full_sql_query full sql query
1998 * @param string $disp_query display query
1999 * @param string $disp_message display message
2000 * @param array $profiling_results profiling results
2001 * @param string $query_type query type
2002 * @param bool $selected whether check table, optimize table, analyze
2003 * table or repair table has been selected with
2004 * respect to the selected tables from the
2005 * database structure page.
2006 * @param string $sql_query sql query
2007 * @param string $complete_query complete sql query
2011 function PMA_sendQueryResponseForResultsReturned($result, $justBrowsing,
2012 $analyzed_sql_results, $db, $table, $disp_mode, $message, $sql_data,
2013 $displayResultsObject, $goto, $pmaThemeImage, $sql_limit_to_append,
2014 $unlim_num_rows, $num_rows, $full_sql_query, $disp_query,
2015 $disp_message, $profiling_results, $query_type, $selected, $sql_query,
2018 // If we are retrieving the full value of a truncated field or the original
2019 // value of a transformed field, show it here
2020 if (isset($_REQUEST['grid_edit']) && $_REQUEST['grid_edit'] == true) {
2021 PMA_sendResponseForGridEdit($result);
2022 // script has exited at this point
2025 // Gets the list of fields properties
2026 if (isset($result) && $result) {
2027 $fields_meta = $GLOBALS['dbi']->getFieldsMeta($result);
2030 // Should be initialized these parameters before parsing
2031 $showtable = isset($showtable) ?
$showtable : null;
2032 $url_query = isset($url_query) ?
$url_query : null;
2034 $response = PMA_Response
::getInstance();
2035 $header = $response->getHeader();
2036 $scripts = $header->getScripts();
2038 // hide edit and delete links:
2039 // - for information_schema
2040 // - if the result set does not contain all the columns of a unique key
2041 // and we are not just browing all the columns of an updatable view
2043 $sele_exp_cls = $analyzed_sql_results['analyzed_sql'][0]['select_expr_clause'];
2046 && trim($sele_exp_cls) == '*'
2047 && PMA_Table
::isUpdatableView($db, $table);
2049 $has_unique = PMA_resultSetContainsUniqueKey(
2050 $db, $table, $fields_meta
2053 $editable = $has_unique ||
$updatableView;
2055 // Displays the results in a table
2056 if (empty($disp_mode)) {
2057 // see the "PMA_setDisplayMode()" function in
2058 // libraries/DisplayResults.class.php
2059 $disp_mode = 'urdr111101';
2061 if (!empty($table) && ($GLOBALS['dbi']->isSystemSchema($db) ||
!$editable)) {
2062 $disp_mode = 'nnnn110111';
2064 if ( isset($_REQUEST['printview']) && $_REQUEST['printview'] == '1') {
2065 $disp_mode = 'nnnn000000';
2068 if (isset($_REQUEST['table_maintenance'])) {
2069 $scripts->addFile('makegrid.js');
2070 $scripts->addFile('sql.js');
2071 if (isset($message)) {
2072 $message = PMA_Message
::success($message);
2073 $table_maintenance_html = PMA_Util
::getMessage(
2074 $message, $GLOBALS['sql_query'], 'success'
2077 $table_maintenance_html .= PMA_getHtmlForSqlQueryResultsTable(
2078 isset($sql_data) ?
$sql_data : null, $displayResultsObject, $db, $goto,
2079 $pmaThemeImage, $url_query, $disp_mode, $sql_limit_to_append,
2080 false, $unlim_num_rows, $num_rows, $showtable, $result, $querytime,
2081 $analyzed_sql_results, false
2083 if (empty($sql_data) ||
($sql_data['valid_queries'] = 1)) {
2084 $response->addHTML($table_maintenance_html);
2089 if (!isset($_REQUEST['printview']) ||
$_REQUEST['printview'] != '1') {
2090 $scripts->addFile('makegrid.js');
2091 $scripts->addFile('sql.js');
2092 unset($GLOBALS['message']);
2093 //we don't need to buffer the output in getMessage here.
2094 //set a global variable and check against it in the function
2095 $GLOBALS['buffer_message'] = false;
2098 $print_view_header_html = PMA_getHtmlForPrintViewHeader(
2099 $db, $full_sql_query, $num_rows
2102 $previous_update_query_html = PMA_getHtmlForPreviousUpdateQuery(
2103 isset($disp_query) ?
$disp_query : null,
2104 $GLOBALS['cfg']['ShowSQL'], isset($sql_data) ?
$sql_data : null,
2105 isset($disp_message) ?
$disp_message : null
2108 $profiling_chart_html = PMA_getHtmlForProfilingChart(
2109 $disp_mode, $db, isset($profiling_results) ?
$profiling_results : null
2112 $missing_unique_column_msg = PMA_getMessageIfMissingColumnIndex(
2113 $table, $db, $editable, $disp_mode
2116 $bookmark_created_msg = PMA_getBookmarkCreatedMessage();
2118 $table_html = PMA_getHtmlForSqlQueryResultsTable(
2119 isset($sql_data) ?
$sql_data : null, $displayResultsObject, $db, $goto,
2120 $pmaThemeImage, $url_query, $disp_mode, $sql_limit_to_append,
2121 $editable, $unlim_num_rows, $num_rows, $showtable, $result,
2122 $analyzed_sql_results
2125 $indexes_problems_html = PMA_getHtmlForIndexesProblems(
2126 isset($query_type) ?
$query_type : null,
2127 isset($selected) ?
$selected : null, $db
2130 $bookmark_support_html = PMA_getHtmlForBookmark(
2132 isset($GLOBALS['cfg']['Bookmark']) ?
$GLOBALS['cfg']['Bookmark'] : '',
2133 $sql_query, $db, $table,
2134 isset($complete_query) ?
$complete_query : $sql_query,
2135 $GLOBALS['cfg']['Bookmark']['user']
2138 $print_button_html = PMA_getHtmlForPrintButton();
2140 $html_output = isset($table_maintenance_html) ?
$table_maintenance_html : '';
2142 $html_output .= isset($print_view_header_html) ?
$print_view_header_html : '';
2144 $html_output .= PMA_getHtmlForSqlQueryResults(
2145 $previous_update_query_html, $profiling_chart_html,
2146 $missing_unique_column_msg, $bookmark_created_msg,
2147 $table_html, $indexes_problems_html, $bookmark_support_html,
2151 $response->addHTML($html_output);
2157 * Function to send response for both empty results and non empty results
2159 * @param int $num_rows number of rows returned by the executed query
2160 * @param int $unlim_num_rows unlimited number of rows
2161 * @param bool $is_affected is affected
2162 * @param string $db current database
2163 * @param string $table current table
2164 * @param string $message_to_show message to show
2165 * @param array $analyzed_sql_results analyzed Sql Results
2166 * @param object $displayResultsObject Instance of DisplayResult class
2167 * @param array $extra_data extra data
2168 * @param array $result executed query results
2169 * @param bool $justBrowsing whether just browsing or not
2170 * @param string $disp_mode disply mode
2171 * @param object $message message
2172 * @param array $sql_data sql data
2173 * @param string $goto goto page url
2174 * @param string $pmaThemeImage uri of the PMA theme image
2175 * @param string $sql_limit_to_append sql limit to append
2176 * @param string $full_sql_query full sql query
2177 * @param string $disp_query display query
2178 * @param string $disp_message display message
2179 * @param array $profiling_results profiling results
2180 * @param string $query_type query type
2181 * @param bool $selected whether check table, optimize table, analyze
2182 * table or repair table has been selected with
2183 * respect to the selected tables from the
2184 * database structure page.
2185 * @param string $sql_query sql query
2186 * @param string $complete_query complete query
2190 function PMA_sendQueryResponse($num_rows, $unlim_num_rows, $is_affected,
2191 $db, $table, $message_to_show, $analyzed_sql_results, $displayResultsObject,
2192 $extra_data, $result, $justBrowsing, $disp_mode,$message, $sql_data,
2193 $goto, $pmaThemeImage, $sql_limit_to_append, $full_sql_query,
2194 $disp_query, $disp_message, $profiling_results, $query_type, $selected,
2195 $sql_query, $complete_query
2197 // No rows returned -> move back to the calling page
2198 if ((0 == $num_rows && 0 == $unlim_num_rows) ||
$is_affected) {
2199 PMA_sendQueryResponseForNoResultsReturned(
2200 $analyzed_sql_results, $db, $table,
2201 isset($message_to_show) ?
$message_to_show : null,
2202 $num_rows, $displayResultsObject, $extra_data
2206 // At least one row is returned -> displays a table with results
2207 PMA_sendQueryResponseForResultsReturned(
2208 isset($result) ?
$result : null, $justBrowsing, $analyzed_sql_results,
2209 $db, $table, isset($disp_mode) ?
$disp_mode : null,
2210 isset($message) ?
$message : null, isset($sql_data) ?
$sql_data : null,
2211 $displayResultsObject, $goto, $pmaThemeImage,
2212 $sql_limit_to_append, $unlim_num_rows,
2213 $num_rows, $full_sql_query,
2214 isset($disp_query) ?
$disp_query : null,
2215 isset($disp_message) ?
$disp_message : null, $profiling_results,
2216 isset($query_type) ?
$query_type : null,
2217 isset($selected) ?
$selected : null, $sql_query,
2218 isset($complete_query) ?
$complete_query : null
2220 } // end rows returned
2224 * Function to execute the query and send the response
2226 * @param array $analyzed_sql_results analysed sql results
2227 * @param bool $is_gotofile whether goto file or not
2228 * @param string $db current database
2229 * @param string $table current table
2230 * @param bool $find_real_end whether to find real end or not
2231 * @param string $import_text import text
2232 * @param array $extra_data extra data
2233 * @param bool $is_affected whether affected or not
2234 * @param string $message_to_show message to show
2235 * @param string $disp_mode display mode
2236 * @param string $message message
2237 * @param array $sql_data sql data
2238 * @param string $goto goto page url
2239 * @param string $pmaThemeImage uri of the PMA theme image
2240 * @param string $disp_query display query
2241 * @param string $disp_message display message
2242 * @param string $query_type query type
2243 * @param string $sql_query sql query
2244 * @param bool $selected whether check table, optimize table, analyze
2245 * table or repair table has been selected with
2246 * respect to the selected tables from the
2247 * database structure page.
2248 * @param string $complete_query complete query
2252 function PMA_executeQueryAndSendQueryResponse($analyzed_sql_results,
2253 $is_gotofile, $db, $table, $find_real_end, $import_text, $extra_data,
2254 $is_affected, $message_to_show, $disp_mode, $message, $sql_data, $goto,
2255 $pmaThemeImage, $disp_query, $disp_message,
2256 $query_type, $sql_query, $selected, $complete_query
2258 // Include PMA_Index class for use in PMA_DisplayResults class
2259 include_once './libraries/Index.class.php';
2261 include 'libraries/DisplayResults.class.php';
2263 $displayResultsObject = new PMA_DisplayResults(
2264 $GLOBALS['db'], $GLOBALS['table'], $GLOBALS['goto'], $GLOBALS['sql_query']
2267 $displayResultsObject->setConfigParamsForDisplayTable();
2269 // assign default full_sql_query
2270 $full_sql_query = $sql_query;
2272 // Handle remembered sorting order, only for single table query
2273 if (PMA_isRememberSortingOrder($analyzed_sql_results)) {
2274 PMA_handleSortOrder($db, $table, $analyzed_sql_results, $full_sql_query);
2277 // Do append a "LIMIT" clause?
2278 if (PMA_isAppendLimitClause($analyzed_sql_results)) {
2279 list($sql_limit_to_append,
2280 $full_sql_query, $analyzed_display_query, $display_query
2281 ) = PMA_appendLimitClause(
2282 $full_sql_query, $analyzed_sql_results['analyzed_sql'],
2283 isset($display_query)
2286 $sql_limit_to_append = '';
2289 $GLOBALS['reload'] = PMA_hasCurrentDbChanged($db);
2291 // Execute the query
2292 list($result, $num_rows, $unlim_num_rows, $profiling_results,
2293 $justBrowsing, $extra_data
2294 ) = PMA_executeTheQuery(
2295 $analyzed_sql_results, $full_sql_query, $is_gotofile, $db, $table,
2296 isset($find_real_end) ?
$find_real_end : null,
2297 isset($import_text) ?
$import_text : null,
2298 isset($extra_data) ?
$extra_data : null
2301 PMA_sendQueryResponse(
2302 $num_rows, $unlim_num_rows, $is_affected, $db, $table,
2303 isset($message_to_show) ?
$message_to_show : null,
2304 $analyzed_sql_results, $displayResultsObject, $extra_data,
2305 isset($result) ?
$result : null, $justBrowsing,
2306 isset($disp_mode) ?
$disp_mode : null, isset($message) ?
$message : null,
2307 isset($sql_data) ?
$sql_data : null,
2308 $goto, $pmaThemeImage, $sql_limit_to_append, $full_sql_query,
2309 isset($disp_query) ?
$disp_query : null,
2310 isset($disp_message) ?
$disp_message : null, $profiling_results,
2311 isset($query_type) ?
$query_type : null, isset($selected) ?
$selected : null,
2312 $sql_query, isset($complete_query) ?
$complete_query : null