123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- declare (strict_types = 1);
- namespace app\command;
- use think\console\Command;
- use think\console\Input;
- use think\console\input\Argument;
- use think\console\input\Option;
- use think\console\Output;
- use think\facade\Db;
- class ResetSql extends Command
- {
- private $delete_tables = [
- 'lab_data',
- 'inspect_report',
- 'exam_report',
- 'medical_orders',
- 'exam_application',
- 'medical_information',
- 'patient',
- 'diagnose',
- 'middle_storage',
- 'mpi',
- 'hospital_patient',
- 'hospital_hrpatient',
- 'bi_inspect_report',
- 'hr_record',
- 'admin_log',
- 'call_record',
- 'crud_log',
- 'del_bi_inspect_report',
- 'del_inspect_report',
- 'del_lab_data',
- 'del_medical_information',
- 'del_exam_report',
- 'del_patient',
- 'repeat_post',
- 'migrations',
- 'token',
- 'zskk_test'
- ];
- protected function configure()
- {
- // 指令配置
-
- $this->setName('resetsql')
- ->setDescription('清空表数据:
- '.implode(',
- ', $this->delete_tables));
- }
- protected function execute(Input $input, Output $output)
- {
- // 指令输出
- $output->writeln('删除表任务开始');
- foreach($this->delete_tables as $table) {
- $this->_deleteTable($output, $table);
- }
- $output->writeln('删除表任务结束');
- }
- protected function _deleteTable(Output $output, string $table)
- {
- $output->writeln('删除表 '.$table.' 数据开始');
- // Db::table($table)->query(true);
- Db::execute("TRUNCATE TABLE $table");
- $output->writeln('删除表 '.$table.' 数据结束');
- }
- }
|