db_qbe.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * query by example the whole database
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. /**
  9. * requirements
  10. */
  11. require_once 'libraries/common.inc.php';
  12. require_once 'libraries/DBQbe.class.php';
  13. $response = PMA_Response::getInstance();
  14. // Gets the relation settings
  15. $cfgRelation = PMA_getRelationsParam();
  16. /**
  17. * A query has been submitted -> (maybe) execute it
  18. */
  19. $message_to_display = false;
  20. if (isset($_REQUEST['submit_sql']) && ! empty($sql_query)) {
  21. if (! preg_match('@^SELECT@i', $sql_query)) {
  22. $message_to_display = true;
  23. } else {
  24. $goto = 'db_sql.php';
  25. include 'sql.php';
  26. exit;
  27. }
  28. }
  29. $sub_part = '_qbe';
  30. require 'libraries/db_common.inc.php';
  31. $url_query .= '&amp;goto=db_qbe.php';
  32. $url_params['goto'] = 'db_qbe.php';
  33. require 'libraries/db_info.inc.php';
  34. if ($message_to_display) {
  35. PMA_Message::error(__('You have to choose at least one column to display'))->display();
  36. }
  37. unset($message_to_display);
  38. // create new qbe search instance
  39. $db_qbe = new PMA_DBQbe($GLOBALS['db']);
  40. /**
  41. * Displays the Query by example form
  42. */
  43. if ($cfgRelation['designerwork']) {
  44. $url = 'pmd_general.php' . PMA_generate_common_url(
  45. array_merge(
  46. $url_params,
  47. array('query' => 1)
  48. )
  49. );
  50. $response->addHTML(
  51. PMA_Message::notice(
  52. sprintf(
  53. __('Switch to %svisual builder%s'),
  54. '<a href="' . $url . '">',
  55. '</a>'
  56. )
  57. )
  58. );
  59. }
  60. $response->addHTML($db_qbe->getSelectionForm($cfgRelation));
  61. ?>