Laravel 5 Eloquent with MongoDB - get array of column names from document -


this becoming frustrating beyond imagination.

i need column names table using eloquent orm in laravel 5 combined mongodb. have found examples, none of them working me made sql specifically. tried this , this without success, idea?

thanks!

it best use raw() method in case , use native mongocollection methods find() iterate on collection , keys in documents array:

// returns array of field names collection of user models. $keys = db::collection('users')->raw(function($collection) {     $cursor = $collection->find();     $array = iterator_to_array($cursor);     $fields = array();     foreach ($array $k=>$v) {         foreach ($v $a=>$b) {             $fields[] = $a;         }     }     return array_values(array_unique($fields));     }); 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -