改进数据表字段缓存读取

This commit is contained in:
thinkphp
2016-09-20 10:45:10 +08:00
parent fe1fd73b93
commit c1a2db30c7
2 changed files with 13 additions and 7 deletions

View File

@@ -72,7 +72,6 @@ class Schema extends Command
$output->writeln('<info>Succeed!</info>');
return;
} else {
$dbName = Db::getConfig('database');
$tables = Db::getTables();
}
@@ -97,11 +96,16 @@ class Schema extends Command
protected function buildDataBaseSchema($tables, $db)
{
if ('' == $db) {
$dbName = Db::getConfig('database') . '.';
} else {
$dbName = $db;
}
foreach ($tables as $table) {
$content = '<?php ' . PHP_EOL . 'return ';
$info = Db::getFields($db . $table);
$content .= var_export($info, true) . ';';
file_put_contents(RUNTIME_PATH . 'schema' . DS . $db . $table . EXT, $content);
file_put_contents(RUNTIME_PATH . 'schema' . DS . $dbName . $table . EXT, $content);
}
}
}