I am trying to get columns name from sql view, my view appear like this:
name type building_id
test type_test 5
test2 type2_test 6
I want to get names(name & type & building_id) I tried Laravel function getColumnListing() but i get null array
Try this
\Illuminate\Support\Facades\DB::select('show columns from table_name');
// table_name must be db table name
Result
array:5 [▼
0 => {#309 ▼
+"Field": "id"
+"Type": "int(10) unsigned"
+"Null": "NO"
+"Key": "PRI"
+"Default": null
+"Extra": "auto_increment"
}
1 => {#311 ▼
+"Field": "name"
+"Type": "varchar(100)"
+"Null": "NO"
+"Key": ""
+"Default": null
+"Extra": ""
}
2 => {#312 ▶}
3 => {#313 ▶}
4 => {#314 ▶}
]