$it) { $item = $it['Tables_in_shop_uniapp']; $currentMatch = ''; foreach ($match as $matchKey => $matchItem) { if (stripos($item, $matchItem) === false) { $currentMatch = ''; } else { $currentMatch = $item; break; } } if ($item != $currentMatch) { $arr[$item] = [ 'comment' => $table_info = Db::query('SHOW TABLE STATUS LIKE ' . "'" . $item . "'")[0]['Comment'], 'children' => Db::query('SHOW FULL COLUMNS FROM `' . $item . '`') ]; } } function createXmdStr(&$res_str, $arr) { foreach ($arr as $key => &$item) { if ($item['comment'] != '') { $res_str .= "\n{$key}\n\t" . $item['comment']; if ($item['children']) { foreach ($item['children'] as $childKey => &$childItem) { if ($childItem['Comment'] == '') { $res_str .= "\n\t\t{$childItem['Field']}"; } else { $childItem['Comment'] = str_replace(",", ',', $childItem['Comment']); $childItem['Comment'] = str_replace("]", ')', $childItem['Comment']); $childItem['Comment'] = str_replace("[", '(', $childItem['Comment']); $res_str .= "\n\t\t{$childItem['Field']}\n\t\t\t{$childItem['Comment']}"; } } } } else { $res_str .= "\n{$key}"; if ($item['children']) { foreach ($item['children'] as $childKey => &$childItem) { if ($childItem['Comment'] == '') { $res_str .= "\n\t{$childItem['Field']}"; } else { $childItem['Comment'] = str_replace(",", ',', $childItem['Comment']); $childItem['Comment'] = str_replace("]", ')', $childItem['Comment']); $childItem['Comment'] = str_replace("[", '(', $childItem['Comment']); $res_str .= "\n\t{$childItem['Field']}\n\t\t{$childItem['Comment']}"; } } } } } } createXmdStr($res_str, $arr); echo $res_str; return ''; } /** * 获取网站tdk详情 */ public function getTdkInfo(Request $request): array { $params = $request->param(); $this->validate($params, ['tdk_type' => 'require']); $find = ModelTdk::field([ 'tdk_id', 'tdk_type', 'tdk_title', 'tdk_description', 'tdk_keyword' ]) ->where('tdk_type', $params['tdk_type']) ->find(); return msg(0, '获取网站tdk详情成功!', ['data' => $find]); } }