开发者

How can I set a default sort for tables in PHPMyAdmin (i.e. always "Primary key - Descending")

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 ascend开发者_开发技巧ing. 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?


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.


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.


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.


@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


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/


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.


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.


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!!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜