title: Finding a nested value in a document using the PHP driver
body: <p>Okay so here is my issue. Each user in my db has field called 'friends'. Each time a friend is added, it gets a unique id and is also keyed in the friends field according to a string typed version of this id, like so:</p>
  
  <pre><code>$user          =   AppDatabase::getInstance()-&gt;getUser($user_id);
  $user_friends  =   $user['friends'];
  $new_friend    =   array
                                      (
                                          'friend_id'=&gt;new MongoId($friend_id),
                                          'nickname'=&gt;(string)$nickname,
                                          'friendpic'=&gt;''
                                      );
  
  $user_friends[(string)$friend_id] = $new_friend;
  </code></pre>
  
  <p>This is all good and works fine, I get a result in the db that looks like this:</p>
  
  <pre><code>'friends':
  {
  503da7ba65d351681a00000c
  {
  'friend_id':{$oid:503da7ba65d351681a00000c},
  'nickname':"Heisenberg",
  'friendpic':''
  }
  }
  </code></pre>
  
  <p>Now, what I need to be able to do is find a friend by only using their friend_id and not knowing the user_id (or anything about the user). I'm a little confused on how to do this, basically the process in my head is:</p>
  
  <ul>
  <li>Pass in the friend's id</li>
  <li>Query the user's collection</li>
  <li>Find all "user_friends" fields</li>
  <li>From this, find the key which matches the id I passed in originally</li>
  <li>End up with the correct friend object</li>
  </ul>
  
  <p>None of what I am trying really works though. Perhaps I have structured the data incorrectly. If someone could put me on the right path I'd really appreciate it. </p>
  
  <p>Cheers!</p>