简体   繁体   中英

php equivalent of rs.conf() in mongodb ?

how can I get the same result as rs.conf() gives. I am trying to get the replicaset node's status through php. So I was wondering if I can get the same output as rs.conf() gives in mongodb shell ?

You can try using MongoDB::execute

Example :

$db->execute('return rs.status();');

You can do it via JS or you can actually go to the database directly via command :

http://docs.mongodb.org/manual/reference/command/replSetGetStatus/#replSetGetStatus

$db->command(array('replSetGetStatus' => 1));

Should be slightly faster than eval ing code and holding a JS global lock.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM