书签¶
注解
为了使用书签功能,你需要配置 phpMyAdmin配置存储 。
存储书签¶
任何被执行的查询都可以在显示结果的页面上被标记为一个书签。你会发现一个标有 将此查询标记为书签 的按钮,就在页面的最后。一旦你存储了一个书签,该查询就被链接到数据库中。现在你可以在每个页面上访问一个书签下拉框,该数据库的查询框出现在该页面上。
在书签中使用变量¶
Inside a query, you can also add placeholders for variables.
This is done by inserting into the query SQL comments between /*
and
*/
. The special string [VARIABLE{variable-number}]
is used inside the comments.
Be aware that the whole query minus the SQL comments must be
valid by itself, otherwise you won’t be able to store it as a bookmark.
Also, note that the text ‘VARIABLE’ is case-sensitive.
When you execute the bookmark, everything typed into the Variables
input boxes on the query box page will replace the strings /*[VARIABLE{variable-number}]*/
in
your stored query.
Also remember, that everything else inside the /*[VARIABLE{variable-number}]*/
string for
your query will remain the way it is, but will be stripped of the /**/
chars. So you can use:
/*, [VARIABLE1] AS myname */
将展开为
, VARIABLE1 as myname
in your query, where VARIABLE1 is the string you entered in the Variable 1 input box.
现在举一个更复杂的例子。假如你保存了这个查询:
SELECT Name, Address FROM addresses WHERE 1 /* AND Name LIKE '%[VARIABLE1]%' */
假如你输入了“phpMyAdmin”作为变量,完整的查询将会是:
SELECT Name, Address FROM addresses WHERE 1 AND Name LIKE '%phpMyAdmin%'
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.
使用书签浏览表格¶
如果书签的名称与表格相同,它将被用作浏览此表时的查询。