mirror of
https://gitee.com/wonderful-code/buildadmin
synced 2024-11-21 22:55:36 +00:00
fix:修复选择数据表、选择数据表字段接口非默认数据库返回空数据的问题
This commit is contained in:
parent
63a79c6240
commit
efa1d7f514
@ -67,8 +67,9 @@ class TableManager
|
|||||||
public static function getTableList(?string $connection = null): array
|
public static function getTableList(?string $connection = null): array
|
||||||
{
|
{
|
||||||
$tableList = [];
|
$tableList = [];
|
||||||
$connection = self::getConnectionConfig($connection);
|
$config = self::getConnectionConfig($connection);
|
||||||
$tables = Db::query("SELECT TABLE_NAME,TABLE_COMMENT FROM information_schema.TABLES WHERE table_schema = ? ", [$connection['database']]);
|
$connection = self::getConnection($connection);
|
||||||
|
$tables = Db::connect($connection)->query("SELECT TABLE_NAME,TABLE_COMMENT FROM information_schema.TABLES WHERE table_schema = ? ", [$config['database']]);
|
||||||
foreach ($tables as $row) {
|
foreach ($tables as $row) {
|
||||||
$tableList[$row['TABLE_NAME']] = $row['TABLE_NAME'] . ($row['TABLE_COMMENT'] ? ' - ' . $row['TABLE_COMMENT'] : '');
|
$tableList[$row['TABLE_NAME']] = $row['TABLE_NAME'] . ($row['TABLE_COMMENT'] ? ' - ' . $row['TABLE_COMMENT'] : '');
|
||||||
}
|
}
|
||||||
@ -87,14 +88,15 @@ class TableManager
|
|||||||
if (!$table) return [];
|
if (!$table) return [];
|
||||||
|
|
||||||
$table = self::tableName($table, true, $connection);
|
$table = self::tableName($table, true, $connection);
|
||||||
$connection = self::getConnectionConfig($connection);
|
$config = self::getConnectionConfig($connection);
|
||||||
|
$connection = self::getConnection($connection);
|
||||||
|
|
||||||
// 从数据库中获取表字段信息
|
// 从数据库中获取表字段信息
|
||||||
// Phinx 目前无法正确获取到列注释信息,故使用 sql
|
// Phinx 目前无法正确获取到列注释信息,故使用 sql
|
||||||
$sql = "SELECT * FROM `information_schema`.`columns` "
|
$sql = "SELECT * FROM `information_schema`.`columns` "
|
||||||
. "WHERE TABLE_SCHEMA = ? AND table_name = ? "
|
. "WHERE TABLE_SCHEMA = ? AND table_name = ? "
|
||||||
. "ORDER BY ORDINAL_POSITION";
|
. "ORDER BY ORDINAL_POSITION";
|
||||||
$columnList = Db::query($sql, [$connection['database'], $table]);
|
$columnList = Db::connect($connection)->query($sql, [$config['database'], $table]);
|
||||||
|
|
||||||
$fieldList = [];
|
$fieldList = [];
|
||||||
foreach ($columnList as $item) {
|
foreach ($columnList as $item) {
|
||||||
|
Loading…
Reference in New Issue
Block a user