public function cleanLogs($m)
{
$m = intval($m);
if ($m == 0) {
return false;
}
// 获取知识表列表
$tableList = D('')->query("SHOW TABLE STATUS LIKE '" . $this->tablePrefix . "x_logs_%'");
$todayInfo = getDate(time());
$diff = getDate(mktime(0, 0, 0, $todayInfo['mon'] - $m, 1, $todayInfo['year']));
foreach ($tableList as $k => $value) {
$table = explode('_', $value['Name']);
if ($table[3] == $diff['year']) {
if ($table[4] <= $diff['mon']) {
$dropTables[] = $value['Name'];
}
} elseif ($table[3] < $diff['year']) {
$dropTables[] = $value['Name'];
}
}
if ($dropTables) {
return D('')->query('DROP TABLE ' . implode(',', $dropTables));
} else {
return false;
}
}