php - How Do I Create a JSON Feed from a MongoDB Collection -


i'm creating cms client work photographs , sell them on site. cms end front end, both ajax, it'd nice json feed setup can use same feed generate new "pages" , "views" js.

so example feed have {[name:'a photo',description:'lorem ipsum...'],[...]} , jquery or js can create table of photographs, pages, etc. how can set myself?

should create php file gets data mongodb put's in array convert array json?

    $cursor = $this->collection->find($params);     $return = array();     $i=0;     while( $cursor->hasnext() )     {          $return[$i] = $cursor->getnext();         // key() function returns records '_id'         $return[$i++]['_id'] = $cursor->key();     }     return json_encode($return); 

that how return json frrom mongo.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -