I have cronjob that runs once a day. I thought to share the code I use to keep nuBuilder clean.
Code: Select all
include "../db/config.php"; //nuBuilder config file
$conn = mysql_connect($DBHost, $DBUser, $DBPassword);
mysql_select_db($DBName,$conn);
/**************************************************************
emptying zzsys_trap and zzsys_variable tables
**************************************************************/
$sql = "TRUNCATE TABLE zzsys_trap";
mysql_query($sql);
$sql = "TRUNCATE TABLE zzsys_variable";
mysql_query($sql);
/**************************************************************
Deleting temp tables
**************************************************************/
$result=mysql_query("SHOW TABLES FROM $DBName ") or die(mysql_error());
if(mysql_num_rows($result)>0)
{
while($row=mysql_fetch_row($result))
{
if(substr($row[0], 0, 3) === '___' && strrev(substr($row[0], 0, 3) === '___'))
{
$sql = "DROP TABLE $row[0]";
mysql_query($sql);
}
}
}