Reputation: 1489
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?
Upvotes: 22
Views: 27785
Reputation: 11
In newer versions of phpMyAdmin you should be able to do a edit in line with the code you want to be as default and set the order by key to PRIMARY (DESC) to achieve what you demand. This set up should be persistent, probably changing the parameter mentioned above $cfg['TablePrimaryKeyOrder'] = 'DESC';
, because there is no access to the phpmyadmin config file to set it yourself in cPanel, it may be better to play with that option instead.
The screenshot was taken while changing from one table to another, it's still loading the results and as you can see the order by key is already set as PRIMARY (DESC) -> you can si the SC, the final result is this as default.
Upvotes: 0
Reputation: 45
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';
Upvotes: 0
Reputation: 209
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!!
Upvotes: -1
Reputation: 651
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.
Upvotes: 33
Reputation: 1
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.
Upvotes: -1
Reputation: 77
You can save a private bookmark with the name of the table you're browsing.
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.
Upvotes: 6
Reputation: 329
@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
Upvotes: 4
Reputation: 15378
Why don't you use heidi SQL
Here's a guide on how:
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
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.
Upvotes: 0
Reputation: 49
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.
Upvotes: 3
Reputation: 48887
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/
Upvotes: 1