bookmarks.txt 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. .. _bookmarks:
  2. Bookmarks
  3. =========
  4. .. note::
  5. You need to have configured the :ref:`linked-tables` for using bookmarks
  6. feature.
  7. Storing bookmarks
  8. -----------------
  9. Any query you have executed can be stored as a bookmark on the page
  10. where the results are displayed. You will find a button labeled
  11. :guilabel:`Bookmark this query` just at the end of the page. As soon as you have
  12. stored a bookmark, it is related to the database you run the query on.
  13. You can now access a bookmark dropdown on each page, the query box
  14. appears on for that database.
  15. Variables inside bookmarks
  16. --------------------------
  17. You can also have, inside the query, placeholders for variables.
  18. This is done by inserting into the query SQL comments between ``/*`` and
  19. ``*/``. Inside the comments, the special strings ``[VARIABLE{variable-number}]`` is used.
  20. Be aware that the whole query minus the SQL comments must be
  21. valid by itself, otherwise you won't be able to store it as a bookmark.
  22. Note also that the text 'VARIABLE' is case-sensitive.
  23. When you execute the bookmark, everything typed into the *Variables*
  24. input boxes on the query box page will replace the strings ``/*[VARIABLE{variable-number}]*/`` in
  25. your stored query.
  26. Also remember, that everything else inside the ``/*[VARIABLE{variable-number}]*/`` string for
  27. your query will remain the way it is, but will be stripped of the ``/**/``
  28. chars. So you can use:
  29. .. code-block:: mysql
  30. /*, [VARIABLE1] AS myname */
  31. which will be expanded to
  32. .. code-block:: mysql
  33. , VARIABLE1 as myname
  34. in your query, where VARIABLE1 is the string you entered in the Variable 1 input box.
  35. A more complex example. Say you have stored
  36. this query:
  37. .. code-block:: mysql
  38. SELECT Name, Address FROM addresses WHERE 1 /* AND Name LIKE '%[VARIABLE1]%' */
  39. Say, you now enter "phpMyAdmin" as the variable for the stored query, the full
  40. query will be:
  41. .. code-block:: mysql
  42. SELECT Name, Address FROM addresses WHERE 1 AND Name LIKE '%phpMyAdmin%'
  43. **NOTE THE ABSENCE OF SPACES** inside the ``/**/`` construct. Any spaces
  44. inserted there will be later also inserted as spaces in your query and may lead
  45. to unexpected results especially when using the variable expansion inside of a
  46. "LIKE ''" expression.
  47. Browsing table using bookmark
  48. -----------------------------
  49. When bookmark is named same as table, it will be used as query when browsing
  50. this table.
  51. .. seealso::
  52. :ref:`faqbookmark`,
  53. :ref:`faq6_22`