yii2 通过mysql show显示表与字段
不废话,直接上代码
/** * 查看数据库结构 * @return mixed */ public function actionDbSchema() { $tables = Yii::$app->db->createCommand("SHOW TABLE STATUS")->queryAll(); foreach ($tables as $key => $table) { $tables[$key]['data'] = Yii::$app->db->createCommand("SHOW FULL COLUMNS FROM " . $table['Name'])->queryAll(); } return $this->render('db-schema', [ 'columns' => $tables, ]); }