“shuffle” action was broken, fixed it
This commit is contained in:
parent
d5c8b70abf
commit
7593f1b65c
1 changed files with 3 additions and 6 deletions
|
@ -219,16 +219,13 @@ if ($opts['revive']) {
|
||||||
|
|
||||||
if ($opts['shuffle']) {
|
if ($opts['shuffle']) {
|
||||||
eecho('randomizing values in «RPos» column...'.N,1);
|
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;
|
$i=0;
|
||||||
while ($row=mysqli_fetch_assoc($res)) {
|
while ($row=mysqli_fetch_assoc($res)) {
|
||||||
|
myq($link,"UPDATE Instances SET RPos={$i} WHERE ID={$row['ID']}");
|
||||||
$i++;
|
$i++;
|
||||||
$buf[$row['ID']]=$i;
|
|
||||||
}
|
}
|
||||||
shuffle($buf);
|
eecho("done! Affected rows: {$i}.\n",1);
|
||||||
foreach ($buf as $key=>$val)
|
|
||||||
myq($link,'UPDATE Instances SET RPos='.$val.' WHERE ID='.$key);
|
|
||||||
eecho('done! Affected rows: '.count($buf).'.'.N,1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($opts['updstats']) {
|
if ($opts['updstats']) {
|
||||||
|
|
Loading…
Reference in a new issue