phpmysqlphpmyadmin

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


Solution

  • 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.