我列出了所有以(例如DB
:)为前缀的表,如下所示:user->id + _
2_my_table
$account = Auth()->user();
$tables = DB::select("SHOW TABLES LIKE '" . $account->id . "_%'");
这有效并返回一个像这样的数组:
array:1 [▼
0 => {#577 ▼
+"Tables_in_mydb (2_%)": "2_country_list"
}
]
为什么将(2_%)
搜索模式添加到Tables_in_mydb
属性中?
这会导致稍后在尝试像这样描述表格时出现问题:
if (count($tables)) {
foreach ($tables as $table) {
$table->columns = DB::select('describe '.$table->Tables_in_mydb);
$table->rows = DB::select('SELECT COUNT(*) AS count FROM '.$table->Tables_in_mydb);
}
}