Fusione vari query come procedere?
-
Ciao a tutti
utilizzo varie query per la pulizia degli archivi mysql di un sito, praticamente mi appare un bottoncino, clicco e cancella delle informazioni nel mysql per allegerirlo e funque farne una pulizia (utenti inattivi, messagi vecchi etc..)
adesso vorrei sapere se è possibile fondere tutte queste quesry in 1 sola query in modo da cliccare 1 bottoncino e avviare tutte le pulizie uniche e non dovrei avviare ogni volta tante query.
Qua inserisco il contenuto di ogni query (sono tutte molto simili e semplici) le vorrei solo fondere in 1 unico files cleanall.php
Spero che mi possiamo aiutare, grazie mille
query singole (funzionano singolamente)
<b>Clean Ads</b>
<br><br><?
if ($_POST){$tabla5 = mysql_query("SELECT * FROM tb_ads WHERE tipo='ads' ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre
while ($registro5 = mysql_fetch_array($tabla5)) { // comienza un bucle que leera todos los registros y ejecutara las ordenes que siguen$igual=$registro5["plan"];
//Todo parece correcto procedemos con la inserccion
$queryz9 = "DELETE FROM tb_ads WHERE tipo='ads' AND members='$igual'";
mysql_query($queryz9) or die(mysql_error());
}echo "<b>Done.</b><br><br>";
}
?>
This Button Will Clean Old Ads.
<br><br>
<form method="post" action="index.php?op=13">
<input type="hidden" name="clean" value="clean">
<input type="submit" Value="Clean" class="button">
</form></table>
<b>Clean Break Frame Ads</b>
<br><br><?
if ($_POST){$tabla5 = mysql_query("SELECT * FROM tb_ads where tipo='ads' ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre
while ($registro5 = mysql_fetch_array($tabla5)) { // comienza un bucle que leera todos los registros y ejecutara las ordenes que siguen$queryz9 = "DELETE FROM tb_ads WHERE
url LIKE '%ucash.in%' OR
url LIKE '%urlcash.net%' OR
url LIKE '%eightteen.com%' OR
url LIKE '%pornyhost.com%' OR
url LIKE '%urlcash.org%' OR
url LIKE '%clb1.com%' OR
url LIKE '%urlgalleries.com%' OR
url LIKE '%celebclk.com%' OR
url LIKE '%looble.net%' OR
url LIKE '%smilinglinks.com%' OR
url LIKE '%peekatmygirlfriend.com%' OR
url LIKE '%hijacked.eu%' OR
url LIKE '%detonating.com%' OR
url LIKE '%bat5.com%' OR
url LIKE '%xxxs.org%' OR
url LIKE '%usercash.com%' OR
url LIKE '%linkbucks.com%' OR
url LIKE '%baberepublic.com%' OR
url LIKE '%blahetc.com%' OR
url LIKE '%linkgalleries.net%' OR
url LIKE '%placepictures.com%' OR
url LIKE '%picturesetc.net%' OR
url LIKE '%qvvo.com%' OR
url LIKE '%realfiles.net%' OR
url LIKE '%seriousfiles.com%' OR
url LIKE '%seriousurls.com%' OR
url LIKE '%thatsprime.com%' OR
url LIKE '%thesegalleries.com%' OR
url LIKE '%thesefiles.com%' OR
url LIKE '%ubucks.net%' OR
url LIKE '%urlpulse.net%' OR
url LIKE '%viraldatabase.com%' OR
url LIKE '%youfap.com%' OR
url LIKE '%djsuonerie.it%'";
mysql_query($queryz9) or die(mysql_error());
}echo "<b>Done.</b><br><br>";
}
?>
This Button Will Clean Break Frame Ads.
<br><br>
<form method="post" action="index.php?op=77">
<input type="hidden" name="clean" value="clean">
<input type="submit" Value="Clean" class="button">
</form></table>
<b>Clean Inactive Members</b>
<br><br><?
if ($_POST)
{
$tabla5 = mysql_query("SELECT * FROM tb_users ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre$olddate=time() - 15552000; // 60*60*24 = 1 day * 180 = 6 months inactive (15552000) $queryz9 = "DELETE FROM tb_users WHERE lastlogdate <'$olddate'"; //comment mysql_query($queryz9) or die(mysql_error()); echo "<b>Done.</b><br><br>";}
?>
This Button Will Clean Inactive Members.
<br><br>
<form method="post" action="index.php?op=34">
<input type="hidden" name="clean" value="clean">
<input type="submit" Value="Clean" class="button">
</form>
<b>Clean Old Messages</b>
<br><br><?
if ($_POST)
{
$tabla5 = mysql_query("SELECT * FROM tb_messenger ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre$olddate=time() - 2592000; // 60*60*24 = 1 day * 30 = 1 month old (2592000) $queryz9 = "DELETE FROM tb_messenger WHERE timestamp <'$olddate'"; //comment mysql_query($queryz9) or die(mysql_error()); echo "<b>Done.</b><br><br>";}
?>
This Button Will Clean Old Messages.
<br><br>
<form method="post" action="index.php?op=38">
<input type="hidden" name="clean" value="clean">
<input type="submit" Value="Clean" class="button">
</form>
<b>Clean Read Messages</b>
<br><br><?
if ($_POST){$tabla5 = mysql_query("SELECT * FROM tb_messenger WHERE status='read' ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre
while ($registro5 = mysql_fetch_array($tabla5)) { // comienza un bucle que leera todos los registros y ejecutara las ordenes que siguen$queryz9 = "DELETE FROM tb_messenger WHERE status='read'";
mysql_query($queryz9) or die(mysql_error());
}echo "<b>Done.</b><br><br>";
}
?>
This Button Will Clean Read Messages.
<br><br>
<form method="post" action="index.php?op=33">
<input type="hidden" name="clean" value="clean">
<input type="submit" Value="Clean" class="button">
</form></table>
<b>Clean Visits</b>
<br><br><?
if ($_POST){$tabla5 = mysql_query("SELECT * FROM tb_ads WHERE tipo='visit' ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre
while ($registro5 = mysql_fetch_array($tabla5)) { // comienza un bucle que leera todos los registros y ejecutara las ordenes que siguen$queryz9 = "DELETE FROM tb_ads WHERE tipo='visit'";
mysql_query($queryz9) or die(mysql_error());
}echo "<b>Done.</b><br><br>";
}
?>
This Button Will Clean Old Visits.
<br><br>
<form method="post" action="index.php?op=32">
<input type="hidden" name="clean" value="clean">
<input type="submit" Value="Clean" class="button">
</form></table>
Vorrei riunire tutte queste funzioni in 1 singola query (cleanall.php) ma non riesco a farlo, spero mi possiamo aiutare
grazie mille, un saluto a tutti
-
Ciao guadagnaeuro,
dovrebbe essere sufficiente unire tutte le query in php in un unico if che sfrutti la variabile POST clean:
if ($_POST['clean']=='clean'){
//tutte le query senza le condizioni if ($_POST){...}
}al posto di
if ($_POST){
//singolo blocco
}(...)
if ($_POST){
//singolo blocco
}
-
Ciao ceccus
sono ancora a livello elementare di mysql e php
per favore puoi scrivermi il codice completo di almeno 3 query fuse?
appena vedo il codice magari capisco come unirle tutte ma se nn me lo scrivi con almeno 3 query non lo capisco
ti ringrazio per l'aiuto e scusami se non ti ho capito ma ancora so poco di php
a presto e grazie
-
<b>Clean Ads</b> <br><br> <? if ($_POST['clean']=='clean'){ $tabla5 = mysql_query("SELECT * FROM tb_ads WHERE tipo='ads' ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre while ($registro5 = mysql_fetch_array($tabla5)) { // comienza un bucle que leera todos los registros y ejecutara las ordenes que siguen $igual=$registro5["plan"]; //Todo parece correcto procedemos con la inserccion $queryz9 = "DELETE FROM tb_ads WHERE tipo='ads' AND members='$igual'"; mysql_query($queryz9) or die(mysql_error()); } $tabla5 = mysql_query("SELECT * FROM tb_ads where tipo='ads' ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre while ($registro5 = mysql_fetch_array($tabla5)) { // comienza un bucle que leera todos los registros y ejecutara las ordenes que siguen $queryz9 = "DELETE FROM tb_ads WHERE url LIKE '%ucash.in%' OR url LIKE '%urlcash.net%' OR url LIKE '%eightteen.com%' OR url LIKE '%pornyhost.com%' OR url LIKE '%urlcash.org%' OR url LIKE '%clb1.com%' OR url LIKE '%urlgalleries.com%' OR url LIKE '%celebclk.com%' OR url LIKE '%looble.net%' OR url LIKE '%smilinglinks.com%' OR url LIKE '%peekatmygirlfriend.com%' OR url LIKE '%hijacked.eu%' OR url LIKE '%detonating.com%' OR url LIKE '%bat5.com%' OR url LIKE '%xxxs.org%' OR url LIKE '%usercash.com%' OR url LIKE '%linkbucks.com%' OR url LIKE '%baberepublic.com%' OR url LIKE '%blahetc.com%' OR url LIKE '%linkgalleries.net%' OR url LIKE '%placepictures.com%' OR url LIKE '%picturesetc.net%' OR url LIKE '%qvvo.com%' OR url LIKE '%realfiles.net%' OR url LIKE '%seriousfiles.com%' OR url LIKE '%seriousurls.com%' OR url LIKE '%thatsprime.com%' OR url LIKE '%thesegalleries.com%' OR url LIKE '%thesefiles.com%' OR url LIKE '%ubucks.net%' OR url LIKE '%urlpulse.net%' OR url LIKE '%viraldatabase.com%' OR url LIKE '%youfap.com%' OR url LIKE '%djsuonerie.it%' "; mysql_query($queryz9) or die(mysql_error()); } echo "<b>Done.</b><br><br>"; $tabla5 = mysql_query("SELECT * FROM tb_users ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre $olddate=time() - 15552000; // 60*60*24 = 1 day * 180 = 6 months inactive (15552000) $queryz9 = "DELETE FROM tb_users WHERE lastlogdate <'$olddate'"; //comment mysql_query($queryz9) or die(mysql_error()); echo "<b>Done.</b><br><br>"; $tabla5 = mysql_query("SELECT * FROM tb_messenger ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre $olddate=time() - 2592000; // 60*60*24 = 1 day * 30 = 1 month old (2592000) $queryz9 = "DELETE FROM tb_messenger WHERE timestamp <'$olddate'"; //comment mysql_query($queryz9) or die(mysql_error()); echo "<b>Done.</b><br><br>"; $tabla5 = mysql_query("SELECT * FROM tb_messenger WHERE status='read' ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre while ($registro5 = mysql_fetch_array($tabla5)) { // comienza un bucle que leera todos los registros y ejecutara las ordenes que siguen $queryz9 = "DELETE FROM tb_messenger WHERE status='read'"; mysql_query($queryz9) or die(mysql_error()); } echo "<b>Done.</b><br><br>"; $tabla5 = mysql_query("SELECT * FROM tb_ads WHERE tipo='visit' ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre while ($registro5 = mysql_fetch_array($tabla5)) { // comienza un bucle que leera todos los registros y ejecutara las ordenes que siguen $queryz9 = "DELETE FROM tb_ads WHERE tipo='visit'"; mysql_query($queryz9) or die(mysql_error()); } echo "<b>Done.</b><br><br>"; } ?> This Button Will Clean Old Visits. <br><br> <form method="post" action="index.php?op=32"> <input type="hidden" name="clean" value="clean"> <input type="submit" Value="Clean" class="button"> </form> </table>Te le ho unite tutte!

-
ciao
ti confermo che la tua soluzione va bene
grazie mille
mi hai risolto davvero una procedura noiosa da fare ogni giorno
grazie mille alla prossima
ciaoooo
Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.
Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.
Con il tuo contributo, questo post potrebbe essere ancora migliore 💗
Registrati Accedi