0

Here $data returns single record from auth_config collection but i have to get only one particular field value $password = $this->input->get_request_header('Password', TRUE); $username = $this->input->get_request_header('Username', TRUE);

    $data=$this->mongo_db->where('login_name',$username)->get('auth_config');

    return $data;
  • that of course should be `json_encode()` as `json_decode()` comes **from** JSON and you want **to** JSON instead. MongoDB does not emit JSON. You are **converting to JSON** from navtive PHP data structures. – Neil Lunn Aug 09 '17 at 06:04
  • it returns the ouput as "_id": { "$id": "59896d8166a002a61a2e7807" }, "company_id": "10", "login_name": "openbrm", "password": "123qwe" } but i want to get only password field value how can i retrieve it – hema anjali Aug 09 '17 at 06:37
  • That's a different question. I'd generally say [look at and read about projection](https://docs.mongodb.com/v3.4/tutorial/project-fields-from-query-results/) but you appear to be using an ORM. Laravel? For which maybe [How to Select Certain Fields in Laravel Eloquent?](https://stackoverflow.com/questions/28530364/how-to-select-certain-fields-in-laravel-eloquent). At any rate, look for answers or [Ask a New Question](https://stackoverflow.com/questions/ask) – Neil Lunn Aug 09 '17 at 06:43
  • thank you i got correct result – hema anjali Aug 09 '17 at 07:19

0 Answers0