File tree Expand file tree Collapse file tree 1 file changed +58
-2
lines changed
Expand file tree Collapse file tree 1 file changed +58
-2
lines changed Original file line number Diff line number Diff line change 1- # thinkphp6.0-databackup
2- thinkphp6.0的数据库自动备份扩展
1+ ### 使用composer进行安装
2+ ~~~
3+ composer require wamkj/thinkphp6.0-databackup
4+ ~~~
5+
6+ ### 引入类文件
7+ ~~~
8+ use wamkj\thinkphp\Backup;
9+ ~~~
10+
11+ ### 配置文件
12+ ~~~
13+ $config=array(
14+ 'path' => './Data/',//数据库备份路径
15+ 'part' => 20971520,//数据库备份卷大小
16+ 'compress' => 0,//数据库备份文件是否启用压缩 0不压缩 1 压缩
17+ 'level' => 9 //数据库备份文件压缩级别 1普通 4 一般 9最高
18+ );
19+ ~~~
20+
21+ ### 实例化
22+ ~~~
23+ $db= new Backup($config);
24+ ~~~
25+
26+ ### 数据类表列表
27+ ~~~
28+ return $this->fetch('index',['list'=>$db->dataList()]);
29+ ~~~
30+ ### 备份文件列表
31+ ~~~
32+ return $this->fetch('importlist',['list'=>$db->fileList()]);
33+ ~~~
34+
35+ ### 备份表
36+ ~~~
37+ $start= $db->setFile($file)->backup($tables[$id], $start);
38+ ~~~
39+
40+ ### 导入表
41+ ~~~
42+ $start= $db->setFile($file)->import($start);
43+ ~~~
44+
45+ ### 删除备份文件
46+ ~~~
47+ $db->delFile($time);
48+ ~~~
49+
50+ ### 修复表
51+ ~~~
52+ $db->repair($tables)
53+ ~~~
54+
55+ ### 优化表
56+ ~~~
57+ $db->optimize($tables)
58+ ~~~
You can’t perform that action at this time.
0 commit comments