title: MongoDB '$or' and regex in PHP
body: <p>I know there are tons of subjects about "MongoDB $or PHP", but I'm unable to understand this;</p>
  
  <p>Assuming I've a collection <code>Compagnies</code>:</p>
  
  <pre><code>$Mongo-&gt;Compagnies-&gt;insert({"Name":"BoldLine", "Service":"Billing", "Description":"Hello World"});
  $Mongo-&gt;Compagnies-&gt;insert({"Name":"Behobe", "Service":"Development", "Description":"Here we are cool"});
  </code></pre>
  
  <p>My need is to execute an 'or' query on this collection, using regex. So I did:</p>
  
  <pre><code>use \MongoRegex as MR;
  
  $regex = new MR ("/B/i");    //Where field contains the letter 'B'
  
  $Mongo-&gt;Compagnies-&gt;find(
      array(
          '$or'   =&gt;  array(
              array(
                  "Name"          =&gt;  $regex,
                  "Service"       =&gt;  $regex,
                  "Description"   =&gt;  $regex
                  )
              )
          )
  );
  </code></pre>
  
  <p>But there is 0 result. Why? The result shouldn't be the 2 lines? 
  Now if I do :</p>
  
  <pre><code>$Mongo-&gt;Compagnies-&gt;find(
      array(
          '$or'   =&gt;  array(
              array(
                  "Name"          =&gt;  $regex,
                  "Service"       =&gt;  $regex
                  )
              )
          )
  );
  </code></pre>
  
  <p>The result will be only the first line. I don't understand why the second line doesn't match the query, because there is also 'B' in the Name. It seems the '$or' operator acts like '$and'.</p>
  
  <p>Did I miss something? How can I select all entities containing the letter 'B' in one of the 3 fields, even if one or more other field doesn't not contain this letter?</p>
  
  <p>Thank you :)</p>