title: MongoDB MapReduce (1.2) PHP with parameter
body: <p>I'm trying to 'parameterize' a MongoDB MapReduce on PHP and seem to be hitting a wall. I feel like I'm missing something obvious since I'm not super experienced in PHP or javascript. I can get the map reduce to work and return what I need if I hard code the value I want it to check.</p>
  <p>For example</p>
  <pre><code>$client = new MongoDB\Client;
  $collection = $client-&gt;selectCollection('collection','responses');        
  $map = new MongoDB\BSON\Javascript('function() { if(this.response == &quot;Yes&quot;) { emit(&quot;matches&quot;, 1)}};');
  $reduce = new MongoDB\BSON\Javascript('function(key, values) { return Array.sum(values)};');
  $out = ['inline' =&gt; 1];
  
  $data = $collection-&gt;mapReduce($map, $reduce, $out);
  
  foreach ($data as $d) {
      var_dump($d);
  }
  </code></pre>
  <p>I would like this <em>if(this.response == &quot;Yes&quot;)</em> &quot;Yes&quot; value to be a variable so I can filter on other responses.</p>
  <p>I've tried a handful of ways and I can't get it to work.</p>
  <p>Any tips or ideas?</p>
  <p>Thanks!</p>