简体   繁体   中英

Does MongoDB::execute uses mongos eval() internally?

The PHP Mongo Driver allows me to execute code in the database. Does this work in sharded environments? I know, that evaluating code with eval() doesn't work in a sharded environment.

$db->execute(
    new MongoCode('SomeFunc(o)', array(
        'o' => array('name' => 'test') 
    ))
);

In short: no.

Longer answer: MongoCode is used for sending JavaScript code to MongoDB in much the same way as if you entered it through Mongo shell. So it's MongoDB's responsibility to run the supplied code - it does not run inside the PHP engine.

UPDATE: I missed that part in your question about sharded environment which quite changes the short answer. ;)

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