Announcement

  •  » Beta testing
  •  » automatic album sort order by reverse id

#1 2013-06-22 22:14:37

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13786

automatic album sort order by reverse id

[Bugtracker] ticket 2809 is not implemented yet but a user needed to reverse sort by album date and I made a quick order in the database. I publish it here because it might be interesting for other people as well.

Code:

create table tmp_album_order (id int, rank int);

insert into tmp_album_order
(
select
    id,
    @row := @row + 1 as row
  from piwigo_categories, (SELECT @row := 0) r
  where id_uppercat is null
  order by id desc
);

update piwigo_categories t1, tmp_album_order t2
  set t1.rank=t2.rank
  where t1.id=t2.id
;

drop table tmp_album_order;

I consider the album date as equivalent to the album id. the trick is the "@row := @row + 1 as row" which acts as a sequence.

Ordering in the same order as id would have been much simpler, of course.

Offline

 
  •  » Beta testing
  •  » automatic album sort order by reverse id

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact