“shuffle” action was broken, fixed it

This commit is contained in:
pezcurrel 2024-08-23 23:35:15 +02:00
parent d5c8b70abf
commit 7593f1b65c

View file

@ -219,16 +219,13 @@ if ($opts['revive']) {
if ($opts['shuffle']) {
eecho('randomizing values in «RPos» column...'.N,1);
$res=myq($link,'SELECT ID FROM Instances');
$res=myq($link,'SELECT ID FROM Instances ORDER BY RAND()');
$i=0;
while ($row=mysqli_fetch_assoc($res)) {
myq($link,"UPDATE Instances SET RPos={$i} WHERE ID={$row['ID']}");
$i++;
$buf[$row['ID']]=$i;
}
shuffle($buf);
foreach ($buf as $key=>$val)
myq($link,'UPDATE Instances SET RPos='.$val.' WHERE ID='.$key);
eecho('done! Affected rows: '.count($buf).'.'.N,1);
eecho("done! Affected rows: {$i}.\n",1);
}
if ($opts['updstats']) {