I am using the legacy MongoDB driver (1.6.x) to connect to a MongoDB (2.4.x) replicaset. I've got "?readPreference=secondary" in my connection string and two MongoDB secondaries on a replicaSet. My connection string includes all the servers:
You can call
$cursor->info() after you've iterated/read from the cursor to get a data structure which contains a
connection_type_desc keys. The
port keys specify which MongoDB server satisfied that particular query.
$cursor = $this->mongoclient->selectDB("test")->selectCollection("test")->find(); $cursor->rewind(); print_r($cursor->info()); //MongoDB Cursor Info