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.' 数据结束'); } }