0

I am using bcit-ci Codeigniter's library for MongoDb, the codeigniter version 3.1 and MongoDb 3.2, having problem in retrieving only one index of array. The where_in is returning the whole array containing object(s). Here's the data structure : Data Structure

I want to get only one object according to the id match. below is the query i written :

$this->mongo_db->select(['email_templates']);
$this->mongo_db->where('_id', new MongoId($vendor_id));
$this->mongo_db->where_in('email_templates.id', [$id]);
$query = $this->mongo_db->get('vendor');

this query is giving the whole array of object(s). I just want the single object which exactly matches the condition.

  • dear @Neil, working on mongodb with codeigniter and working with codeigniter is too different. The reference you given is not relevant to what i am asking. – Nitin Soni Jun 15 '17 at 14:02
  • Show that you tried it in your question. You only need to add one line. But I'm guessing you simply did not read the linked answer. – Neil Lunn Jun 15 '17 at 14:06
  • when i use row() and row()->field , it says that Call to a member function row() on array. – Nitin Soni Jun 16 '17 at 06:36

0 Answers0