3 // vim: expandtab sw=4 ts=4 sts=4:
5 * @todo we must handle the case if sql.php is called directly with a query
6 * what returns 0 rows - to prevent cyclic redirects or includes
10 * Gets some core libraries
12 require_once './libraries/common.lib.php';
13 require_once './libraries/Table.class.php';
14 require_once './libraries/tbl_indexes.lib.php';
15 require_once './libraries/check_user_privileges.lib.php';
16 require_once './libraries/bookmark.lib.php';
19 * Could be coming from a subform ("T" column expander)
21 if (isset($_REQUEST['dontlimitchars'])) {
22 $dontlimitchars = $_REQUEST['dontlimitchars'];
26 * Defines the url to return to in case of error in a sql statement
30 $is_gotofile = preg_replace('@^([^?]+).*$@s', '\\1', $goto);
31 if (!@file_exists
('./' . $is_gotofile)) {
34 $is_gotofile = ($is_gotofile == $goto);
36 } // end if (security checkings)
39 $goto = (! isset($table) ||
! strlen($table)) ?
$cfg['DefaultTabDatabase'] : $cfg['DefaultTabTable'];
42 if (!isset($err_url)) {
43 $err_url = (!empty($back) ?
$back : $goto)
44 . '?' . PMA_generate_common_url(isset($db) ?
$db : '')
45 . ((strpos(' ' . $goto, 'db_details') != 1 && isset($table)) ?
'&table=' . urlencode($table) : '');
48 // Coming from a bookmark dialog
49 if (isset($fields['query'])) {
50 $sql_query = $fields['query'];
53 // This one is just to fill $db
54 if (isset($fields['dbase'])) {
55 $db = $fields['dbase'];
58 // Default to browse if no query set an we have table
59 // (needed for browsing from DefaultTabTable)
60 if (! isset($sql_query) && isset($table) && isset($db)) {
61 require_once './libraries/bookmark.lib.php';
62 $book_sql_query = PMA_queryBookmarks($db,
63 $GLOBALS['cfg']['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'',
66 if (! empty($book_sql_query)) {
67 $sql_query = $book_sql_query;
69 $sql_query = 'SELECT * FROM ' . PMA_backquote($table);
71 unset($book_sql_query);
73 // set $goto to what will be displayed if query returns 0 rows
74 $goto = 'tbl_properties_structure.php';
76 // Now we can check the parameters
77 PMA_checkParameters(array('sql_query'));
80 // instead of doing the test twice
81 $is_drop_database = preg_match('/DROP[[:space:]]+(DATABASE|SCHEMA)[[:space:]]+/i',
85 * Check rights in case of DROP DATABASE
87 * This test may be bypassed if $is_js_confirmed = 1 (already checked with js)
88 * but since a malicious user may pass this variable by url/form, we don't take
89 * into account this case.
91 if (!defined('PMA_CHK_DROP')
92 && !$cfg['AllowUserDropDatabase']
95 require_once './libraries/header.inc.php';
96 PMA_mysqlDie($strNoDropDatabases, '', '', $err_url);
101 * Need to find the real end of rows?
104 if (isset($find_real_end) && $find_real_end) {
105 $unlim_num_rows = PMA_Table
::countRecords($db, $table, true, true);
106 $pos = @((ceil($unlim_num_rows / $session_max_rows) - 1) * $session_max_rows);
109 * Avoids undefined variables
111 elseif (!isset($pos)) {
118 if (isset($store_bkm)) {
119 PMA_addBookmarks($fields, $cfg['Bookmark'], (isset($bkm_all_users) && $bkm_all_users == 'true' ?
true : false));
120 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . $goto);
125 * Gets the true sql query
127 // $sql_query has been urlencoded in the confirmation form for drop/delete
128 // queries or in the navigation bar for browsing among records
129 if (isset($btnDrop) ||
isset($navig)) {
130 $sql_query = urldecode($sql_query);
134 * Parse and analyze the query
136 require_once('./libraries/parse_analyze.lib.php');
139 * Sets or modifies the $goto variable if required
141 if ($goto == 'sql.php') {
142 $is_gotofile = false;
144 . PMA_generate_common_url($db, $table)
146 . '&sql_query=' . urlencode($sql_query);
151 * Go back to further page if table should not be dropped
153 if (isset($btnDrop) && $btnDrop == $strNo) {
158 if (strpos(' ' . $goto, 'db_details') == 1 && isset($table) && strlen($table)) {
161 $active_page = $goto;
162 require './' . PMA_securePath($goto);
164 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . str_replace('&', '&', $goto));
171 * Displays the confirm page if required
173 * This part of the script is bypassed if $is_js_confirmed = 1 (already checked
174 * with js) because possible security issue is not so important here: at most,
175 * the confirm message isn't displayed.
177 * Also bypassed if only showing php code.or validating a SQL query
180 ||
(isset($is_js_confirmed) && $is_js_confirmed)
183 // if we are coming from a "Create PHP code" or a "Without PHP Code"
184 // dialog, we won't execute the query anyway, so don't confirm
185 //|| !empty($GLOBALS['show_as_php'])
186 ||
isset($GLOBALS['show_as_php'])
188 ||
!empty($GLOBALS['validatequery'])) {
191 $do_confirm = isset($analyzed_sql[0]['queryflags']['need_confirm']);
195 $stripped_sql_query = $sql_query;
196 require_once './libraries/header.inc.php';
197 if ($is_drop_database) {
198 echo '<h1 class="warning">' . $strDropDatabaseStrongWarning . '</h1>';
200 echo '<form action="sql.php" method="post">' . "\n"
201 .PMA_generate_common_hidden_inputs($db, (isset($table)?
$table:''));
203 <input type
="hidden" name
="sql_query" value
="<?php echo urlencode($sql_query); ?>" />
204 <input type
="hidden" name
="zero_rows" value
="<?php echo isset($zero_rows) ? PMA_sanitize($zero_rows) : ''; ?>" />
205 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
206 <input type
="hidden" name
="back" value
="<?php echo isset($back) ? PMA_sanitize($back) : ''; ?>" />
207 <input type
="hidden" name
="reload" value
="<?php echo isset($reload) ? PMA_sanitize($reload) : 0; ?>" />
208 <input type
="hidden" name
="purge" value
="<?php echo isset($purge) ? PMA_sanitize($purge) : ''; ?>" />
209 <input type
="hidden" name
="cpurge" value
="<?php echo isset($cpurge) ? PMA_sanitize($cpurge) : ''; ?>" />
210 <input type
="hidden" name
="purgekey" value
="<?php echo isset($purgekey) ? PMA_sanitize($purgekey) : ''; ?>" />
211 <input type
="hidden" name
="show_query" value
="<?php echo isset($show_query) ? PMA_sanitize($show_query) : ''; ?>" />
213 echo '<fieldset class="confirmation">' . "\n"
214 .' <legend>' . $strDoYouReally . '</legend>'
215 .' <tt>' . htmlspecialchars($stripped_sql_query) . '</tt>' . "\n"
216 .'</fieldset>' . "\n"
217 .'<fieldset class="tblFooters">' . "\n";
219 <input type
="submit" name
="btnDrop" value
="<?php echo $strYes; ?>" id
="buttonYes" />
220 <input type
="submit" name
="btnDrop" value
="<?php echo $strNo; ?>" id
="buttonNo" />
222 echo '</fieldset>' . "\n"
226 * Displays the footer and exit
228 require_once './libraries/footer.inc.php';
229 } // end if $do_confirm
233 * Executes the query and displays results
235 if (!isset($sql_query)) {
239 // Defines some variables
240 // A table has to be created or renamed -> left frame should be reloaded
242 * @todo use the parser/analyzer
246 && preg_match('/^(CREATE|ALTER|DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i', $sql_query)) {
249 // Gets the number of rows per page
250 if (empty($session_max_rows)) {
251 $session_max_rows = $cfg['MaxRows'];
252 } elseif ($session_max_rows != 'all') {
253 $cfg['MaxRows'] = $session_max_rows;
255 // Defines the display mode (horizontal/vertical) and header "frequency"
256 if (empty($disp_direction)) {
257 $disp_direction = $cfg['DefaultDisplay'];
259 if (empty($repeat_cells)) {
260 $repeat_cells = $cfg['RepeatCells'];
263 // SK -- Patch: $is_group added for use in calculation of total number of
265 // $is_count is changed for more correct "LIMIT" clause
266 // appending in queries like
267 // "SELECT COUNT(...) FROM ... GROUP BY ..."
270 * @todo detect all this with the parser, to avoid problems finding
271 * those strings in comments or backquoted identifiers
274 $is_explain = $is_count = $is_export = $is_delete = $is_insert = $is_affected = $is_show = $is_maint = $is_analyse = $is_group = $is_func = $is_replace = false;
275 if ($is_select) { // see line 141
276 $is_group = preg_match('@(GROUP[[:space:]]+BY|HAVING|SELECT[[:space:]]+DISTINCT)[[:space:]]+@i', $sql_query);
277 $is_func = !$is_group && (preg_match('@[[:space:]]+(SUM|AVG|STD|STDDEV|MIN|MAX|BIT_OR|BIT_AND)\s*\(@i', $sql_query));
278 $is_count = !$is_group && (preg_match('@^SELECT[[:space:]]+COUNT\((.*\.+)?.*\)@i', $sql_query));
279 $is_export = (preg_match('@[[:space:]]+INTO[[:space:]]+OUTFILE[[:space:]]+@i', $sql_query));
280 $is_analyse = (preg_match('@[[:space:]]+PROCEDURE[[:space:]]+ANALYSE@i', $sql_query));
281 } elseif (preg_match('@^EXPLAIN[[:space:]]+@i', $sql_query)) {
283 } elseif (preg_match('@^DELETE[[:space:]]+@i', $sql_query)) {
286 } elseif (preg_match('@^(INSERT|LOAD[[:space:]]+DATA|REPLACE)[[:space:]]+@i', $sql_query)) {
289 if (preg_match('@^(REPLACE)[[:space:]]+@i', $sql_query)) {
292 } elseif (preg_match('@^UPDATE[[:space:]]+@i', $sql_query)) {
294 } elseif (preg_match('@^SHOW[[:space:]]+@i', $sql_query)) {
296 } elseif (preg_match('@^(CHECK|ANALYZE|REPAIR|OPTIMIZE)[[:space:]]+TABLE[[:space:]]+@i', $sql_query)) {
300 // Do append a "LIMIT" clause?
302 && (!$cfg['ShowAll'] ||
$session_max_rows != 'all')
303 && !($is_count ||
$is_export ||
$is_func ||
$is_analyse)
304 && isset($analyzed_sql[0]['queryflags']['select_from'])
305 && !isset($analyzed_sql[0]['queryflags']['offset'])
306 && !preg_match('@[[:space:]]LIMIT[[:space:]0-9,-]+(;)?$@i', $sql_query)) {
307 $sql_limit_to_append = " LIMIT $pos, ".$cfg['MaxRows'] . " ";
309 $full_sql_query = $analyzed_sql[0]['section_before_limit'] . "\n" . $sql_limit_to_append . $analyzed_sql[0]['section_after_limit'];
311 * @todo pretty printing of this modified query
313 if (isset($display_query)) {
314 // if the analysis of the original query revealed that we found
315 // a section_after_limit, we now have to analyze $display_query
316 // to display it correctly
318 if (!empty($analyzed_sql[0]['section_after_limit']) && trim($analyzed_sql[0]['section_after_limit']) != ';') {
319 $analyzed_display_query = PMA_SQP_analyze(PMA_SQP_parse($display_query));
320 $display_query = $analyzed_display_query[0]['section_before_limit'] . "\n" . $sql_limit_to_append . $analyzed_display_query[0]['section_after_limit'];
325 $full_sql_query = $sql_query;
329 PMA_DBI_select_db($db);
332 // If the query is a DELETE query with no WHERE clause, get the number of
333 // rows that will be deleted (mysql_affected_rows will always return 0 in
335 // Note: testing shows that this no longer applies since MySQL 4.0.x
337 if (PMA_MYSQL_INT_VERSION
< 40000) {
339 && preg_match('@^DELETE([[:space:]].+)?(FROM[[:space:]](.+))$@i', $sql_query, $parts)
340 && !preg_match('@[[:space:]]WHERE[[:space:]]@i', $parts[3])) {
341 $cnt_all_result = @PMA_DBI_try_query
('SELECT COUNT(*) as count ' . $parts[2]);
342 if ($cnt_all_result) {
343 list($num_rows) = PMA_DBI_fetch_row($cnt_all_result);
344 PMA_DBI_free_result($cnt_all_result);
351 // E x e c u t e t h e q u e r y
353 // Only if we didn't ask to see the php code (mikebeck)
354 if (isset($GLOBALS['show_as_php']) ||
!empty($GLOBALS['validatequery'])) {
358 // garvin: Measure query time.
359 // TODO-Item http://sourceforge.net/tracker/index.php?func=detail&aid=571934&group_id=23067&atid=377411
360 $querytime_before = array_sum(explode(' ', microtime()));
362 $result = @PMA_DBI_try_query
($full_sql_query, null, PMA_DBI_QUERY_STORE
);
364 $querytime_after = array_sum(explode(' ', microtime()));
366 $GLOBALS['querytime'] = $querytime_after - $querytime_before;
368 // Displays an error message if required and stop parsing the script
369 if ($error = PMA_DBI_getError()) {
370 require_once './libraries/header.inc.php';
371 $full_err_url = (preg_match('@^(db_details|tbl_properties)@', $err_url))
372 ?
$err_url . '&show_query=1&sql_query=' . urlencode($sql_query)
374 PMA_mysqlDie($error, $full_sql_query, '', $full_err_url);
378 // Gets the number of rows affected/returned
379 // (This must be done immediately after the query because
380 // mysql_affected_rows() reports about the last query done)
383 $num_rows = ($result) ? @PMA_DBI_num_rows
($result) : 0;
384 } elseif (!isset($num_rows)) {
385 $num_rows = @PMA_DBI_affected_rows
();
388 // Checks if the current database has changed
389 // This could happen if the user sends a query like "USE `database`;"
390 $res = PMA_DBI_query('SELECT DATABASE() AS \'db\';');
391 $row = PMA_DBI_fetch_row($res);
392 if (isset($db) && is_array($row) && isset($row[0]) && (strcasecmp($db, $row[0]) != 0)) {
396 @PMA_DBI_free_result
($res);
399 // tmpfile remove after convert encoding appended by Y.Kawada
400 if (function_exists('PMA_kanji_file_conv')
401 && (isset($textfile) && file_exists($textfile))) {
405 // Counts the total number of rows for the same 'SELECT' query without the
406 // 'LIMIT' clause that may have been programatically added
408 if (empty($sql_limit_to_append)) {
409 $unlim_num_rows = $num_rows;
410 // if we did not append a limit, set this to get a correct
411 // "Showing rows..." message
412 $GLOBALS['session_max_rows'] = 'all';
413 } elseif ($is_select) {
415 // c o u n t q u e r y
417 // If we are "just browsing", there is only one table,
418 // and no where clause (or just 'WHERE 1 '),
419 // so we do a quick count (which uses MaxExactCount)
420 // because SQL_CALC_FOUND_ROWS
421 // is not quick on large InnoDB tables
423 // but do not count again if we did it previously
424 // due to $find_real_end == true
427 && !isset($analyzed_sql[0]['queryflags']['union'])
428 && !isset($analyzed_sql[0]['table_ref'][1]['table_name'])
429 && (empty($analyzed_sql[0]['where_clause'])
430 ||
$analyzed_sql[0]['where_clause'] == '1 ')
431 && !isset($find_real_end)
434 // "j u s t b r o w s i n g"
435 $unlim_num_rows = PMA_Table
::countRecords($db, $table, true);
437 } else { // n o t " j u s t b r o w s i n g "
439 if (PMA_MYSQL_INT_VERSION
< 40000) {
442 // SELECT DISTINCT x AS foo, y AS bar FROM sometable
444 if (isset($analyzed_sql[0]['queryflags']['distinct'])) {
445 $count_what = 'DISTINCT ';
447 foreach ($analyzed_sql[0]['select_expr'] as $part) {
448 $count_what .= (!$first_expr ?
', ' : '') . $part['expr'];
454 // this one does not apply to VIEWs
455 $count_query = 'SELECT COUNT(' . $count_what . ') AS count';
458 // add the remaining of select expression if there is
459 // a GROUP BY or HAVING clause
460 if (PMA_MYSQL_INT_VERSION
< 40000
462 && (!empty($analyzed_sql[0]['group_by_clause'])
463 ||
!empty($analyzed_sql[0]['having_clause']))) {
464 $count_query .= ' ,' . $analyzed_sql[0]['select_expr_clause'];
467 if (PMA_MYSQL_INT_VERSION
>= 40000) {
468 // add select expression after the SQL_CALC_FOUND_ROWS
470 // for UNION, just adding SQL_CALC_FOUND_ROWS
471 // after the first SELECT works.
473 // take the left part, could be:
476 $count_query = PMA_SQP_formatHtml($parsed_sql, 'query_only', 0, $analyzed_sql[0]['position_of_first_select'] +
1);
477 $count_query .= ' SQL_CALC_FOUND_ROWS ';
478 // add everything that was after the first SELECT
479 $count_query .= PMA_SQP_formatHtml($parsed_sql, 'query_only', $analyzed_sql[0]['position_of_first_select']+
1);
480 // ensure there is no semicolon at the end of the
481 // count query because we'll probably add
482 // a LIMIT 1 clause after it
483 $count_query = rtrim($count_query);
484 $count_query = rtrim($count_query, ';');
485 } else { // PMA_MYSQL_INT_VERSION < 40000
487 if (!empty($analyzed_sql[0]['from_clause'])) {
488 $count_query .= ' FROM ' . $analyzed_sql[0]['from_clause'];
490 if (!empty($analyzed_sql[0]['where_clause'])) {
491 $count_query .= ' WHERE ' . $analyzed_sql[0]['where_clause'];
493 if (!empty($analyzed_sql[0]['group_by_clause'])) {
494 $count_query .= ' GROUP BY ' . $analyzed_sql[0]['group_by_clause'];
496 if (!empty($analyzed_sql[0]['having_clause'])) {
497 $count_query .= ' HAVING ' . $analyzed_sql[0]['having_clause'];
501 // if using SQL_CALC_FOUND_ROWS, add a LIMIT to avoid
502 // long delays. Returned count will be complete anyway.
503 // (but a LIMIT would disrupt results in an UNION)
505 if (PMA_MYSQL_INT_VERSION
>= 40000
506 && !isset($analyzed_sql[0]['queryflags']['union'])) {
507 $count_query .= ' LIMIT 1';
510 // run the count query
512 if (PMA_MYSQL_INT_VERSION
< 40000) {
513 if ($cnt_all_result = PMA_DBI_try_query($count_query)) {
514 if ($is_group && $count_what == '*') {
515 $unlim_num_rows = @PMA_DBI_num_rows
($cnt_all_result);
517 $unlim_num_rows = PMA_DBI_fetch_assoc($cnt_all_result);
518 $unlim_num_rows = $unlim_num_rows['count'];
520 PMA_DBI_free_result($cnt_all_result);
522 if (PMA_DBI_getError()) {
524 // there are some cases where the generated
525 // count_query (for MySQL 3) is wrong,
528 * @todo use a big unlimited query to get the correct
529 * number of rows (depending on a config variable?)
535 PMA_DBI_try_query($count_query);
536 // if (mysql_error()) {
539 // (SELECT `User`, `Host`, `Db`, `Select_priv` FROM `db`)
540 // UNION (SELECT `User`, `Host`, "%" AS "Db",
542 // FROM `user`) ORDER BY `User`, `Host`, `Db`;
543 // and although the generated count_query is wrong
544 // the SELECT FOUND_ROWS() work! (maybe it gets the
545 // count from the latest query that worked)
547 // another case where the count_query is wrong:
548 // SELECT COUNT(*), f1 from t1 group by f1
549 // and you click to sort on count(*)
551 $cnt_all_result = PMA_DBI_query('SELECT FOUND_ROWS() as count;');
552 list($unlim_num_rows) = PMA_DBI_fetch_row($cnt_all_result);
553 @PMA_DBI_free_result
($cnt_all_result);
555 } // end else "just browsing"
557 } else { // not $is_select
559 } // end rows total count
561 // garvin: if a table or database gets dropped, check column comments.
562 if (isset($purge) && $purge == '1') {
563 require_once './libraries/relation_cleanup.lib.php';
565 if (isset($table) && isset($db) && strlen($table) && strlen($db)) {
566 PMA_relationsCleanupTable($db, $table);
567 } elseif (isset($db) && strlen($db)) {
568 PMA_relationsCleanupDatabase($db);
570 // garvin: VOID. No DB/Table gets deleted.
571 } // end if relation-stuff
574 // garvin: If a column gets dropped, do relation magic.
575 if (isset($cpurge) && $cpurge == '1' && isset($purgekey)
576 && isset($db) && isset($table)
577 && strlen($db) && strlen($table) && !empty($purgekey)) {
578 require_once './libraries/relation_cleanup.lib.php';
579 PMA_relationsCleanupColumn($db, $table, $purgekey);
581 } // end if column PMA_* purge
582 } // end else "didn't ask to see php code"
584 // No rows returned -> move back to the calling page
585 if ($num_rows < 1 ||
$is_affected) {
587 $message = $strDeletedRows . ' ' . $num_rows;
588 } elseif ($is_insert) {
590 /* For replace we get DELETED + INSERTED row count, so we have to call it affected */
591 $message = $strAffectedRows . ' ' . $num_rows;
593 $message = $strInsertedRows . ' ' . $num_rows;
595 $insert_id = PMA_DBI_insert_id();
596 if ($insert_id != 0) {
597 // insert_id is id of FIRST record inserted in one insert, so if we inserted multiple rows, we had to increment this
598 $message .= '[br]'.$strInsertedRowId . ' ' . ($insert_id +
$num_rows - 1);
600 } elseif ($is_affected) {
601 $message = $strAffectedRows . ' ' . $num_rows;
603 // Ok, here is an explanation for the !$is_select.
604 // The form generated by sql_query_form.lib.php
605 // and db_details.php has many submit buttons
606 // on the same form, and some confusion arises from the
607 // fact that $zero_rows is sent for every case.
608 // The $zero_rows containing $strSuccess and sent with
609 // the form should not have priority over
610 // errors like $strEmptyResultSet
611 } elseif (!empty($zero_rows) && !$is_select) {
612 $message = $zero_rows;
613 } elseif (!empty($GLOBALS['show_as_php'])) {
615 } elseif (!empty($GLOBALS['validatequery'])) {
616 $message = $strValidateSQL;
618 $message = $strEmptyResultSet;
621 $message .= ' ' . (isset($GLOBALS['querytime']) ?
'(' . sprintf($strQueryTime, $GLOBALS['querytime']) . ')' : '');
624 $goto = PMA_securePath($goto);
625 // Checks for a valid target script
626 $is_db = $is_table = false;
627 include 'libraries/db_table_exists.lib.php';
628 if (strpos($goto, 'tbl_properties') === 0 && ! $is_table) {
632 $goto = 'db_details.php';
634 if (strpos($goto, 'db_details') === 0 && ! $is_db) {
640 // Loads to target script
641 if (strpos($goto, 'db_details') === 0
642 ||
strpos($goto, 'tbl_properties') === 0) {
643 $js_to_run = 'functions.js';
645 if ($goto != 'main.php') {
646 require_once './libraries/header.inc.php';
648 $active_page = $goto;
649 require './' . $goto;
651 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . str_replace('&', '&', $goto) . '&message=' . urlencode($message));
654 } // end no rows returned
656 // At least one row is returned -> displays a table with results
658 // Displays the headers
659 if (isset($show_query)) {
662 if (isset($printview) && $printview == '1') {
663 require_once './libraries/header_printview.inc.php';
665 $js_to_run = 'functions.js';
667 if (isset($table) && strlen($table)) {
668 require './libraries/tbl_properties_common.php';
669 $url_query .= '&goto=tbl_properties.php&back=tbl_properties.php';
670 require './libraries/tbl_properties_table_info.inc.php';
671 require './libraries/tbl_properties_links.inc.php';
672 } elseif (isset($db) && strlen($db)) {
673 require './libraries/db_details_common.inc.php';
674 require './libraries/db_details_db_info.inc.php';
676 require './libraries/server_common.inc.php';
677 require './libraries/server_links.inc.php';
681 if (isset($db) && strlen($db)) {
682 require_once './libraries/relation.lib.php';
683 $cfgRelation = PMA_getRelationsParam();
686 // Gets the list of fields properties
687 if (isset($result) && $result) {
688 $fields_meta = PMA_DBI_get_fields_meta($result);
689 $fields_cnt = count($fields_meta);
692 // Display previous update query (from tbl_replace)
693 if (isset($disp_query) && $cfg['ShowSQL'] == true) {
694 $tmp_sql_query = $GLOBALS['sql_query'];
695 $GLOBALS['sql_query'] = $disp_query;
696 PMA_showMessage($disp_message);
697 $GLOBALS['sql_query'] = $tmp_sql_query;
700 // Displays the results in a table
701 require_once './libraries/display_tbl.lib.php';
702 if (empty($disp_mode)) {
703 // see the "PMA_setDisplayMode()" function in
704 // libraries/display_tbl.lib.php
705 $disp_mode = 'urdr111101';
707 if (!isset($dontlimitchars)) {
711 // hide edit and delete links for information_schema
712 if (PMA_MYSQL_INT_VERSION
>= 50002 && isset($db) && $db == 'information_schema') {
713 $disp_mode = 'nnnn110111';
716 PMA_displayTable($result, $disp_mode, $analyzed_sql);
717 PMA_DBI_free_result($result);
719 // BEGIN INDEX CHECK See if indexes should be checked.
720 if (isset($query_type) && $query_type == 'check_tbl' && isset($selected) && is_array($selected)) {
721 foreach ($selected AS $idx => $tbl_name) {
722 $indexes = $indexes_info = $indexes_data = array();
723 $tbl_ret_keys = PMA_get_indexes(urldecode($tbl_name), $err_url_0);
725 PMA_extract_indexes($tbl_ret_keys, $indexes, $indexes_info, $indexes_data);
727 $idx_collection = PMA_show_indexes(urldecode($tbl_name), $indexes, $indexes_info, $indexes_data, false);
728 $check = PMA_check_indexes($idx_collection);
729 if (!empty($check)) {
731 <table border
="0" cellpadding
="2" cellspacing
="0">
733 <td
class="tblHeaders" colspan
="7"><?php
printf($strIndexWarningTable, urldecode($tbl_name)); ?
></td
>
735 <?php
echo $check; ?
>
742 // Bookmark Support if required
743 if ($disp_mode[7] == '1'
744 && (isset($cfg['Bookmark']) && $cfg['Bookmark']['db'] && $cfg['Bookmark']['table'] && empty($id_bookmark))
745 && !empty($sql_query)) {
749 . PMA_generate_common_url($db, $table)
751 . '&session_max_rows=' . $session_max_rows
752 . '&disp_direction=' . $disp_direction
753 . '&repeat_cells=' . $repeat_cells
754 . '&dontlimitchars=' . $dontlimitchars
755 . '&sql_query=' . urlencode($sql_query)
756 . '&id_bookmark=1';
759 <form action
="sql.php" method
="post" onsubmit
="return emptyFormElements(this, 'fields[label]');">
760 <?php
echo PMA_generate_common_hidden_inputs(); ?
>
761 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
762 <input type
="hidden" name
="fields[dbase]" value
="<?php echo htmlspecialchars($db); ?>" />
763 <input type
="hidden" name
="fields[user]" value
="<?php echo $cfg['Bookmark']['user']; ?>" />
764 <input type
="hidden" name
="fields[query]" value
="<?php echo urlencode(isset($complete_query) ? $complete_query : $sql_query); ?>" />
767 echo ($cfg['PropertiesIconic'] ?
'<img class="icon" src="' . $pmaThemeImage . 'b_bookmark.png" width="16" height="16" alt="' . $strBookmarkThis . '" />' : '')
772 <div
class="formelement">
773 <label
for="fields_label_"><?php
echo $strBookmarkLabel; ?
>:</label
>
774 <input type
="text" id
="fields_label_" name
="fields[label]" value
="" />
777 <div
class="formelement">
778 <input type
="checkbox" name
="bkm_all_users" id
="bkm_all_users" value
="true" />
779 <label
for="bkm_all_users"><?php
echo $strBookmarkAllUsers; ?
></label
>
782 <div
class="clearfloat"></div
>
784 <fieldset
class="tblFooters">
785 <input type
="submit" name
="store_bkm" value
="<?php echo $strBookmarkThis; ?>" />
789 } // end bookmark support
791 // Do print the page if required
792 if (isset($printview) && $printview == '1') {
794 <script type
="text/javascript" language
="javascript">
797 window
.onload
= function()
799 if (typeof(window
.print) != 'undefined') {
807 } // end rows returned
810 * Displays the footer
812 require_once './libraries/footer.inc.php';