如何在 PHPMyAdmin 中设置表的默认排序(即始终“主键 - 降序”)

发布于 2024-09-03 12:49:07 字数 169 浏览 3 评论 0原文

尽管它在很多方面令人讨厌,但我在编写 PHP 时一直使用 PHPMyAdmin 来调试数据库问题。默认情况下,它按主键升序对表进行排序。 99% 的情况下,我宁愿默认将最新数据(我的测试数据)显示在顶部,而不是保存的无用的前几条记录。

有没有办法配置 PHPMyAdmin 默认显示最新记录?改变类似的行为?

Even though its obnoxious in a lot of ways I use PHPMyAdmin all the time to debug database issues while writing PHP. By default it sorts tables by primary key ascending. 99% of the time I would rather have the newest data (my test data) shown at the top by default rather than the useless first few records ever saved.

Is there a way to configure PHPMyAdmin to show the newest records by default? To alter similar behavior?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

无边思念无边月 2024-09-10 12:49:07

对于来这里寻找答案的其他人:

在 phpMyAdmin 4.5.0 中,也许在早期版本中,您可以设置 $cfg['TablePrimaryKeyOrder'] 配置如下:

$cfg['TablePrimaryKeyOrder'] = 'DESC';

当外部没有定义排序顺序时,这定义了具有主键的表的默认排序顺序。可接受的值:['NONE'、'ASC'、'DESC']

如果表具有主键并且未对其应用其他排序,则这将设置默认排序。

For anyone else who comes here looking for an answer:

In phpMyAdmin 4.5.0, maybe in earlier versions too, you can set the $cfg['TablePrimaryKeyOrder'] config like so:

$cfg['TablePrimaryKeyOrder'] = 'DESC';

This defines the default sort order for the tables, having a primary key, when there is no sort order defines externally. Acceptable values : [‘NONE’, ‘ASC’, ‘DESC’]

This sets the default sort if the table has a primary key and that no other sort has been applied to it.

做个少女永远怀春 2024-09-10 12:49:07

您可以使用您正在浏览的表的名称保存私人书签。

请参阅https://phpmyadmin.readthedocs.org/en/latest/faq.html#bookmarks-can-i-execute-a-default-bookmark-automatically-when-entering-browse-表格模式

6.22 书签:进入表格浏览模式时可以自动执行默认书签吗?

是的。如果书签与表名具有相同标签并且不是公共书签,则会执行该书签。

You can save a private bookmark with the name of the table you're browsing.

See https://phpmyadmin.readthedocs.org/en/latest/faq.html#bookmarks-can-i-execute-a-default-bookmark-automatically-when-entering-browse-mode-for-a-table

6.22 Bookmarks: Can I execute a default bookmark automatically when entering Browse mode for a table?

Yes. If a bookmark has the same label as a table name and it’s not a public bookmark, it will be executed.

初心 2024-09-10 12:49:07

@jeremyclarke,在 phpMyAdmin v3.4.5 中,登录后单击“主页”
然后,
从“更多”菜单中选择“设置”
单击“主框架”选项卡,然后单击“浏览模式”选项卡

,您会发现“默认排序顺序”,默认模式设置为 SMART
因此,选择“ASC”或“DESC”

如果执行上述步骤,它将保存当前会话,

永久保存将其设置在config.php中
http://wiki.phpmyadmin.net/pma/Config#Order

@jeremyclarke, in phpMyAdmin v3.4.5, after login click "home"
then,
from "More" menu choose "Settings"
click "Main frame" tab, then "Browse mode" tab

There you'll find "Default sorting order" the default mode is set to SMART
hence, choose "ASC" or "DESC"

If you do the above steps, it will be saved for the current session,

to save it permanently set it in config.php
http://wiki.phpmyadmin.net/pma/Config#Order

虐人心 2024-09-10 12:49:07

我认为你可以做到这一点。去一张桌子->操作并按降序设置更改表顺序。
下次您浏览时,您首先会看到最新的行。

i think you can do this. Go to a table -> operations and set alter table order by descending.
Next time when ever you browse you get the newest row first.

智商已欠费 2024-09-10 12:49:07

默认情况下,它按主排序对表进行排序
键升序

phpMyAdmin 默认情况下根本不执行任何排序。它只是询问表中的所有记录,然后由 MySQL 决定顺序。

有没有办法配置PHPMyAdmin
默认显示最新记录?
改变类似的行为?

没有办法做到这一点,因为 phpMyAdmin 必须了解每个表的每个主键(假设有一个,并且只有一个)以及如何对其进行排序。

phpMyAdmin 支持书签查询。您可以 DESC 然后为其添加书签。但是,如果您的目标是减少点击次数,它肯定不会减少点击次数。

http://www.phpmyadmin.net/documentation/

By default it sorts tables by primary
key ascending

phpMyAdmin isn't performing any sorting at all by default. It's simply asking for all records in a table and MySQL is deciding the order.

Is there a way to configure PHPMyAdmin
to show the newest records by default?
To alter similar behavior?

There's no way to do this as phpMyAdmin would have to be informed about every primary key of every table (assuming there is one, and only one) and how to sort it.

phpMyAdmin does support bookmarking queries. You could DESC and then bookmark that. However, it certainly won't minimize the number of clicks, if that's what you're aim is.

http://www.phpmyadmin.net/documentation/

初见 2024-09-10 12:49:07

为什么不使用 heidi SQL

以下是有关如何操作的指南:

启用从主机登录。

首先,获取您的 IP 地址 - http://www.whatismyip.com
希望这是一个静态 IP,否则您将有一些不太安全的选项(如下)

您将需要访问权限才能在数据库上创建用户。您可以通过 Cpanel 或 PHP My Admin 来执行此操作(假设您具有正确的访问级别)。如果您不确定,请谷歌获取说明。如果失败,您可以尝试运行此查询:

CREATE USER 'jason'@'your_ip_here' IDENTIFIED BY 'your_password_here';
GRANT ALL PRIVILEGES ON database_name.* TO 'jason'@'your_ip_here';

如果您没有静态 IP 地址,那么您可以考虑使用通配符,尽管这不太安全。另一个更安全的选项是 SSH 隧道

下载并安装 Heidi SQL

http://www.heidisql.com/download.php

运行安装(当然在 Windows 上)

最后,设置连接,连接。

您会发现 heidi 允许您轻松地对数据列表进行排序,http://www .heidisql.com/screenshots.php?which=data
它还会记住排序和过滤器。

Why don't you use heidi SQL

Here's a guide on how:

Enable login from your host pc.

First of all, get your IP Address - http://www.whatismyip.com
Hopefully that's a static IP, otherwise you have some less secure options (below)

You'll need access to create a user on the database. You can do this through Cpanel, or in PHP My Admin (assuming you have the right level of access). Google for instructions if you are unsure. Fail that you can attemtp to run this query:

CREATE USER 'jason'@'your_ip_here' IDENTIFIED BY 'your_password_here';
GRANT ALL PRIVILEGES ON database_name.* TO 'jason'@'your_ip_here';

If you don't have a static IP Address then you can consider using a wildcard, although this is less secure. Another more secure option is SSH tunneling

Download and install Heidi SQL

http://www.heidisql.com/download.php

Run the install (on windows ofcourse)

Finally, setup your connection, connect.

You'll find that heidi allows you to easily sort the listing of data, http://www.heidisql.com/screenshots.php?which=data
It also remembers sorts and filters too.

故事未完 2024-09-10 12:49:07

只需将此行添加到您的 PHPMyAdmin 配置文件中即可。

在大多数 PHPMyAdmin 版本中,配置文件是 config.inc.php

$cfg['TablePrimaryKeyOrder'] = 'DESC';

Just add this line to your PHPMyAdmin configuration file.

in most of PHPMyAdmin versions, the configuration file will be config.inc.php

$cfg['TablePrimaryKeyOrder'] = 'DESC';
如歌彻婉言 2024-09-10 12:49:07

我使用的是 phpMyAdmin 版本 4.2.3(英文),我只是更新了位于 Libraries 目录中的 DatabaseInterface.class.php 文件中第 488 行的排序顺序变量。行号(也可能是文件)在其他版本中可能会有所不同。

public function getTablesFull($database, $table = false,
    $tbl_is_group = false,$link = null,$limit_offset = 0,
    limit_count = false, $sort_by = '名称', $sort_order = 'DESC',
    $表类型=空

当我打开文件时,变量 $sort_order 等于“ASC”。自从将其更改为 DESC 并通过 FTP 上传后,我的表的排序顺序(在日期 (DATETIME) 上唯一键入)始终为 DESC(首先是最近添加的记录)。

不确定这是否是所有情况的最佳解决方案,但是 满足我的需要。

希望这能

I'm using phpMyAdmin version 4.2.3 (English) and I simply updated the sort order variable on line 488 in the DatabaseInterface.class.php file which resides in the Libraries directory. The line number (and possibly the file) may vary in other versions.

public function getTablesFull($database, $table = false,
    $tbl_is_group = false,  $link = null, $limit_offset = 0,
    limit_count = false, $sort_by = 'Name', $sort_order = 'DESC',
    $tble_type = null

The variable $sort_order was equal to 'ASC' when I opened the file. Since changing it to DESC and uploading via FTP, the sort order for my table (which is uniquely keyed on date (DATETIME) is always DESC (most recently added records first).

Not sure if this is the best solution for all cases, but it suits my needs.

Hopefully this helps.

花开柳相依 2024-09-10 12:49:07

以上答案都不适合我,我使用的是 PHPMyAdmin 5.2.0

您可以编辑 PHPMyAdmin 的以下文件并将排序顺序设置为 DESC

文件路径:/usr/share/phpmyadmin/库/类/Config/Settings.php
函数:setTablePrimaryKeyOrder()

只需在setTablePrimaryKeyOrder() 函数的开头设置如下设置变量即可。

$settings['TablePrimaryKeyOrder'] = 'DESC';

你就可以走了!

None of the above answer work for me, I am using PHPMyAdmin 5.2.0

You can edit the below file for PHPMyAdmin and set the sort order as DESC

Filepath: /usr/share/phpmyadmin/libraries/classes/Config/Settings.php
function: setTablePrimaryKeyOrder()

Just set the setting variables as below at the start of the setTablePrimaryKeyOrder() function.

$settings['TablePrimaryKeyOrder'] = 'DESC';

and you're good to GO!!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文