// +---------------------------------------------------------------------- namespace think\console\command\optimize; use think\console\Command; use think\console\Input; use think\console\input\Option; use think\console\Output; use think\Db; class Schema extends Command { /** @var Output */ protected $output; protected function configure() { $this->setName('optimize:schema') ->addOption('db', null, Option::VALUE_REQUIRED, 'db name .') ->addOption('table', null, Option::VALUE_REQUIRED, 'table name .') ->setDescription('Build database schema cache.'); } protected function execute(Input $input, Output $output) { if ($input->hasOption('table')) { $tables[] = $input->getOption('table'); } else { if ($input->hasOption('db')) { $dbName = $input->getOption('db'); $tables = Db::getTables($dbName); } else { $tables = Db::getTables(); } } if (!is_dir(RUNTIME_PATH . 'schema')) { @mkdir(RUNTIME_PATH . 'schema', 0755, true); } $db = isset($dbName) ? $dbName . '.' : ''; foreach ($tables as $table) { $content = 'writeln('Succeed!'); } }