MongoDB + PHP driver: running map-reduce on secondaries
If you got here, you already know that by now PHP driver (<= 1.2) for Mongo don’t do queries on secondary using the setSlaveOkay() method.
You can use this quick&dirty hack:
$result = $_mongo->selectCollection(’$cmd’)->find(array(“group” => array(
“ns” => “collectionName”,
’$key’ => $key,
’$condition’ => $condition,
‘initial’ => $initial,
’$reduce’ => $reduce
)))->slaveOkay()->limit(1)->getNext();
That should solve your problem.
February 12, 2012