bookmarks.rst.txt 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 that is executed can be marked 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, that query is linked to the database.
  13. You can now access a bookmark dropdown on each page where the query box appears on for that database.
  14. Variables inside bookmarks
  15. --------------------------
  16. Inside a query, you can also add placeholders for variables.
  17. This is done by inserting into the query SQL comments between ``/*`` and
  18. ``*/``. The special string ``[VARIABLE{variable-number}]`` is used inside the comments.
  19. Be aware that the whole query minus the SQL comments must be
  20. valid by itself, otherwise you won't be able to store it as a bookmark.
  21. Also, note that the text 'VARIABLE' is case-sensitive.
  22. When you execute the bookmark, everything typed into the *Variables*
  23. input boxes on the query box page will replace the strings ``/*[VARIABLE{variable-number}]*/`` in
  24. your stored query.
  25. Also remember, that everything else inside the ``/*[VARIABLE{variable-number}]*/`` string for
  26. your query will remain the way it is, but will be stripped of the ``/**/``
  27. chars. So you can use:
  28. .. code-block:: mysql
  29. /*, [VARIABLE1] AS myname */
  30. which will be expanded to
  31. .. code-block:: mysql
  32. , VARIABLE1 as myname
  33. in your query, where VARIABLE1 is the string you entered in the Variable 1 input box.
  34. A more complex example, say you have stored this query:
  35. .. code-block:: mysql
  36. SELECT Name, Address FROM addresses WHERE 1 /* AND Name LIKE '%[VARIABLE1]%' */
  37. If you wish to enter "phpMyAdmin" as the variable for the stored query, the full
  38. query will be:
  39. .. code-block:: mysql
  40. SELECT Name, Address FROM addresses WHERE 1 AND Name LIKE '%phpMyAdmin%'
  41. **NOTE THE ABSENCE OF SPACES** inside the ``/**/`` construct. Any spaces
  42. inserted there will be later also inserted as spaces in your query and may lead
  43. to unexpected results especially when using the variable expansion inside of a
  44. "LIKE ''" expression.
  45. Browsing a table using a bookmark
  46. ---------------------------------
  47. When a bookmark has the same name as the table, it will be used as the query when browsing
  48. this table.
  49. .. seealso::
  50. :ref:`faqbookmark`,
  51. :ref:`faq6_22`