function get_init_field($table){
            //$table=$this->request->param('model');
            $dbname = Config::get('database.database');
            $prefix = Config::get('database.prefix');
            $sql="select COLUMN_NAME ,DATA_TYPE from information_schema.COLUMNS where TABLE_SCHEMA = ? and table_name = ? and DATA_TYPE = 'int'";
            $columnList = Db::query($sql, [$dbname, $table]);
            $fieldlist = [];
            foreach ($columnList as $index => $item) {
            $fieldlist[] = $item['COLUMN_NAME'];
            }
            return json($fieldlist);
}

名词解释

$table 即为表名
$dbname 数据库名
$prefix 数据库前缀

命令

select COLUMN_NAME ,DATA_TYPE from information_schema.COLUMNS where TABLE_SCHEMA ='washbox' and table_name = 'fa_user' and DATA_TYPE = 'int';

标签: none