首页 > 技术文章 > 数据表备份

CWQPHP 2021-03-03 08:52 原文

//备份数据表
$time = time();
Db()->execute('CREATE TABLE table1_'. $time . ' LIKE table1');
Db()->execute('insert into table1_' . $time . ' select * from table1');

Db()->execute('CREATE TABLE table2_' . $time . ' LIKE table2');
Db()->execute('insert into table2_' . $time . ' select * from table2');

//清空原表
Db()->execute('TRUNCATE TABLE `table1`');

Db()->execute('TRUNCATE TABLE `table2`');

推荐阅读