/**
* @自动清除smarty缓存
* @pageroute
*/
function clear_cache()
{
$cmd = sprintf("sudo rm -fr %s >> %s 2>&1",__APP_CACHE_PATH__ . '/smarty/cache/*',__APP_LOGS_PATH__ . '/cache-clear.log');
logs(sprintf("cache-clear %s \n",date('Y-m-d H:i:s')),'cache-clear.log');
shell_exec($cmd);
}
/**
* @导出数据库数据
* @pageroute
*/
function exportData()
{
$sql = "SHOW TABLES";
$tables = (new \Model\Model())->query($sql)->resultArr();
//var_dump($tables);die;
$path = '/var/project/htdocs/wb_test/data';
$tpl = "<?php\n\n return %s;";
foreach ($tables as $table) {
$table = array_pop($table);
$model = new \Model\Model($table);
$result = $model->listTable('',0,1000)->resultArr();
if ($result) {
$s = var_export($result,true);
}else {
$s = 'array()';
}
$file = $path . '/' . $table . '.php';
$content = sprintf($tpl,$s);
file_put_contents($file,$content);
}
}