From 7593f1b65c753c6365ca7432ae4dd4843c201379 Mon Sep 17 00:00:00 2001 From: pezcurrel Date: Fri, 23 Aug 2024 23:35:15 +0200 Subject: [PATCH] =?UTF-8?q?=E2=80=9Cshuffle=E2=80=9D=20action=20was=20brok?= =?UTF-8?q?en,=20fixed=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/clitools/mustool.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/web/clitools/mustool.php b/web/clitools/mustool.php index 1ee36af..370d7ae 100755 --- a/web/clitools/mustool.php +++ b/web/clitools/mustool.php @@ -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']) {