pmd_display_field.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * @package PhpMyAdmin-Designer
  5. */
  6. /**
  7. *
  8. */
  9. require_once './libraries/common.inc.php';
  10. PMA_Response::getInstance()->disable();
  11. require_once 'libraries/pmd_common.php';
  12. $post_params = array(
  13. 'T',
  14. 'F'
  15. );
  16. foreach ($post_params as $one_post_param) {
  17. if (isset($_POST[$one_post_param])) {
  18. $GLOBALS[$one_post_param] = $_POST[$one_post_param];
  19. }
  20. }
  21. $table = $T;
  22. $display_field = $F;
  23. if ($cfgRelation['displaywork']) {
  24. $disp = PMA_getDisplayField($db, $table);
  25. if ($disp) {
  26. if ($display_field != $disp) {
  27. $upd_query = 'UPDATE ' . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_Util::backquote($cfgRelation['table_info'])
  28. . ' SET display_field = \'' . PMA_Util::sqlAddSlashes($display_field) . '\''
  29. . ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\''
  30. . ' AND table_name = \'' . PMA_Util::sqlAddSlashes($table) . '\'';
  31. } else {
  32. $upd_query = 'DELETE FROM ' . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_Util::backquote($cfgRelation['table_info'])
  33. . ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\''
  34. . ' AND table_name = \'' . PMA_Util::sqlAddSlashes($table) . '\'';
  35. }
  36. } elseif ($display_field != '') {
  37. $upd_query = 'INSERT INTO ' . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_Util::backquote($cfgRelation['table_info'])
  38. . '(db_name, table_name, display_field) '
  39. . ' VALUES('
  40. . '\'' . PMA_Util::sqlAddSlashes($db) . '\','
  41. . '\'' . PMA_Util::sqlAddSlashes($table) . '\','
  42. . '\'' . PMA_Util::sqlAddSlashes($display_field) . '\')';
  43. }
  44. if (isset($upd_query)) {
  45. $upd_rs = PMA_queryAsControlUser($upd_query);
  46. }
  47. } // end if
  48. header("Content-Type: text/xml; charset=utf-8");
  49. header("Cache-Control: no-cache");
  50. die("<root act='save_pos' return='" . __('Modifications have been saved') . "'></root>");
  51. ?>