Created
May 9, 2012 08:25
-
-
Save oniryx/2642948 to your computer and use it in GitHub Desktop.
Init sortable_rank when using propel with sortable behavior
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Init sortable_rank without scope */ | |
select @rank:=0; | |
update TABLE_NAME set sortable_rank=(@rank:=(@rank+1)); | |
/* Init sortable_rank with scope */ | |
select @range:=0; | |
update TABLE_NAME set sortable_rank=IF(@range!=SCOPE_COLUMN, @rank:=1 && (@range:=SCOPE_COLUMN), @rank:=@rank+1) order by SCOPE_COLUMN, PK_COLUMN; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment