Using new form of delinstbyuid function; removed references to New column

This commit is contained in:
pezcurrel 2022-12-18 18:27:22 +01:00
parent 835e02c171
commit cd16eabce5

View file

@ -40,7 +40,7 @@ $help='mustool.php
First it returns a list of Instances records matching “condition”, then First it returns a list of Instances records matching “condition”, then
lets you choose whether you want to delete them and all records referencing lets you choose whether you want to delete them and all records referencing
them in other tables. them in other tables.
Example: mustool.php deleteinstswhere "New=0 AND Dead=1" Example: mustool.php deleteinstswhere "Dead=1"
shuffle shuffle
Randomizes instances list (values in «RPos» column). Randomizes instances list (values in «RPos» column).
updstats updstats
@ -115,12 +115,6 @@ catch (Exception $error) { mexit('could not set «utf8mb4» charset for MySQL: '
// for php versions < 8 // for php versions < 8
if ($res===false) mexit('could not set MySQL charset: '.mysqli_errno($link).': '.mysqli_error($link).'.'.N,1,true); if ($res===false) mexit('could not set MySQL charset: '.mysqli_errno($link).': '.mysqli_error($link).'.'.N,1,true);
/*if ($opts['setold']) {
echo('Setting «New=0» for instances which are no longer new ... ');
myq($link,'UPDATE Instances SET New=0 WHERE '.time().'-FirstSeen > '.$opts['setold_new_period']);
echo('done! Affected rows: '.mysqli_affected_rows($link).'.'.N);
}*/
if ($opts['deleteinstswhere']) { if ($opts['deleteinstswhere']) {
$res=myq($link,'SELECT ID, URI FROM Instances WHERE '.$opts['deleteinstswhereconds']); $res=myq($link,'SELECT ID, URI FROM Instances WHERE '.$opts['deleteinstswhereconds']);
$buf=[]; $buf=[];
@ -135,9 +129,8 @@ if ($opts['deleteinstswhere']) {
foreach ($buf as $row) { foreach ($buf as $row) {
$i++; $i++;
echo('Deleting Instances record with ID = '.$row['ID'].' and URI = «'.$row['URI'].'», and all references to it ('.$i.'/'.$cbuf.', '.round(100/$cbuf*$i,2).'%) ...'.N); echo('Deleting Instances record with ID = '.$row['ID'].' and URI = «'.$row['URI'].'», and all references to it ('.$i.'/'.$cbuf.', '.round(100/$cbuf*$i,2).'%) ...'.N);
$res=delinstbyid($link,$row['ID']); $res=delinstbyid($link,$row['ID'],'eecho',N);
foreach ($res['log'] as $loge) echo($loge.N); if (!$res) mexit('Error trying to delete Instances record with ID='.$row['ID'].'; see the log above for more info.'.N);
if (!$res['ok']) mexit('Error trying to delete Instances record with ID='.$row['ID'].'; see the log above for more info.'.N);
if ($i<$cbuf) echo('---'.N); if ($i<$cbuf) echo('---'.N);
} }
} }
@ -289,4 +282,8 @@ function mexit($msg,$code) {
exit($code); exit($code);
} }
function eecho($msg) {
echo($msg);
}
?> ?>