title: Check if value (string) exist in Mongo DB query in PHP 7
body: <p>I need to check if string exist in MongoDB query in PHP7. In old days it was easy like so:</p>
  
  <pre><code>// Trying to find $username
  
  $dbserver = new MongoClient();
  $db = $dbserver-&gt;databasename;
  $collection = $db-&gt;collectionname;
  $queryDbFind = $collection-&gt;findOne(array("user" =&gt; $username));
  if(empty($queryDbFind[$username])){
      echo "empty";
  } else {
      echo "not empty";
  };
  </code></pre>
  
  <p>Now there is new PHP driver, where i perform query as follows:</p>
  
  <pre><code>$db = new MongoDB\Driver\Manager("mongodb://localhost:27017")
  $query1 = new MongoDB\Driver\Query(['user' =&gt; $username], ['limit' =&gt; 1, 'projection' =&gt; ['user' =&gt; 1, '_id' =&gt; 0]]);
  $dbread1 = $db-&gt;executeQuery('goodcv.userbase', $query1);
  </code></pre>
  
  <p>This is where I am stuck. I get the object, but can not check if $username exist in that object.</p>
  
  <p>I have tried:</p>
  
  <pre><code>$result1 = $dbread1-&gt;toArray();
  if(empty($result1-&gt;user)){
          echo "user exist";
      } else {
          echo "user does not exist";
      };
  </code></pre>
  
  <p>Does not work :(
  Only way to return result is:</p>
  
  <pre><code>foreach($result1 as $row){
      echo $row-&gt;user;
  };
  </code></pre>
  
  <p>But this is not proper way to do it right?</p>