FAQ 6.18

From PmaWiki

Jump to: navigation, search

[edit] Bookmarks: Where can I store bookmarks? Why can't I see any bookmarks below the query box? What is this variable for?

Any query you have executed can be stored as a bookmark on the page where the results are displayed. You will find a button labeled 'Bookmark this query' just at the end of the page. As soon as you have stored a bookmark, it is related to the database you run the query on. You can now access a bookmark dropdown on each page, the query box appears on for that database.

Since phpMyAdmin 2.5.0 you are also able to store variables for the bookmarks. Just use the string /*[VARIABLE]*/ anywhere in your query. Everything which is put into the value input box on the query box page will replace the string "/*[VARIABLE]*/" in your stored query. Just be aware of that you HAVE to create a valid query, otherwise your query won't be even able to be stored in the database. Also remember, that everything else inside the /*[VARIABLE]*/ string for your query will remain the way it is, but will be stripped of the /**/ chars. So you can use:

/*, [VARIABLE] AS myname */

which will be expanded to

, VARIABLE as myname

in your query, where VARIABLE is the string you entered in the input box. If an empty string is provided, no replacements are made.

A more complex example. Say you have stored this query:

SELECT Name, Address FROM addresses WHERE 1 /* AND Name LIKE '%[VARIABLE]%' */

Say, you now enter "phpMyAdmin" as the variable for the stored query, the full query will be:

SELECT Name, Address FROM addresses WHERE 1 AND Name LIKE '%phpMyAdmin%'

You can use multiple occurrences of /*[VARIABLE]*/ in a single query. NOTE THE ABSENCE OF SPACES inside the "/**/" construct. Any spaces inserted there will be later also inserted as spaces in your query and may lead to unexpected results especially when using the variable expansion inside of a "LIKE " expression. Your initial query which is going to be stored as a bookmark has to yield at least one result row so you can store the bookmark. You may have that to work around using well positioned "/**/" comments.

Personal tools
Advertisement