mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
改进数据表字段缓存读取
This commit is contained in:
@@ -72,7 +72,6 @@ class Schema extends Command
|
|||||||
$output->writeln('<info>Succeed!</info>');
|
$output->writeln('<info>Succeed!</info>');
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
$dbName = Db::getConfig('database');
|
|
||||||
$tables = Db::getTables();
|
$tables = Db::getTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,11 +96,16 @@ class Schema extends Command
|
|||||||
|
|
||||||
protected function buildDataBaseSchema($tables, $db)
|
protected function buildDataBaseSchema($tables, $db)
|
||||||
{
|
{
|
||||||
|
if ('' == $db) {
|
||||||
|
$dbName = Db::getConfig('database') . '.';
|
||||||
|
} else {
|
||||||
|
$dbName = $db;
|
||||||
|
}
|
||||||
foreach ($tables as $table) {
|
foreach ($tables as $table) {
|
||||||
$content = '<?php ' . PHP_EOL . 'return ';
|
$content = '<?php ' . PHP_EOL . 'return ';
|
||||||
$info = Db::getFields($db . $table);
|
$info = Db::getFields($db . $table);
|
||||||
$content .= var_export($info, true) . ';';
|
$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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1341,13 +1341,15 @@ class Query
|
|||||||
}
|
}
|
||||||
|
|
||||||
list($guid) = explode(' ', $tableName);
|
list($guid) = explode(' ', $tableName);
|
||||||
if (!strpos($guid, '.')) {
|
|
||||||
$guid = $this->getConfig('database') . '.' . $guid;
|
|
||||||
}
|
|
||||||
if (!isset(self::$info[$guid])) {
|
if (!isset(self::$info[$guid])) {
|
||||||
|
if (!strpos($guid, '.')) {
|
||||||
|
$schema = $this->getConfig('database') . '.' . $guid;
|
||||||
|
} else {
|
||||||
|
$schema = $guid;
|
||||||
|
}
|
||||||
// 读取缓存
|
// 读取缓存
|
||||||
if (is_file(RUNTIME_PATH . 'schema/' . $guid . '.php')) {
|
if (is_file(RUNTIME_PATH . 'schema/' . $schema . '.php')) {
|
||||||
$info = include RUNTIME_PATH . 'schema/' . $guid . '.php';
|
$info = include RUNTIME_PATH . 'schema/' . $schema . '.php';
|
||||||
} else {
|
} else {
|
||||||
$info = $this->connection->getFields($guid);
|
$info = $this->connection->getFields($guid);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user