Blogger Information
Blog 3
fans 0
comment 0
visits 3332
Related recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php自定义函数
幸运儿的博客
Original
611 people have browsed it

/**

 * @自动清除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);

    }

}


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post