pmd_display_field.php 2.0 KB

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