php - How can I select some columns of table? -


here code:

$arr = users::all()->toarray(); 

it returns array of table's columns. don't need columns. need return these columns: 'id', 'name', 'email', 'age'. i've searched , figured out: (using pluck() function)

$arr = users::pluck('id', 'name', 'email', 'age')->toarray(); 

but doesn't return expected result. returns this:

array:7 [▼   "john" => 1   "peter" => 2   "jack" => 3   "ali" => 4   "teresco" => 5   "mark" => 6   "barman" => 7 ] 

as see, there isn't email , age columns. how can fix it?

you can collect arrays of columns in get() this:

$arr = users::get(array('id', 'name', 'email', 'age'))->toarray(); 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -