Table Columns as Array

Submitted by decipher - 9 months ago

Sometimes you need to want tables columns as array while you editing the data, this will return a columns as array.

static function getColumns($table){
        $query = "SHOW columns FROM `{$table}`";
        $columns = [];
        foreach(\DB::select($query) as $key)
        {
            $columns[$key->Field] = '';
        }
        return $columns;
}
comments powered by Disqus