php mongodb findandmodify not working -


i using php , mongodb. want use findandmodify. field { "_id" : objectid("58d37e612d4ffa498b99c2d4"), "userid" : "1234", "active_time" : "hai" }

i want modify active_time. example change value "hai" "1234"

i using mongodb\driver\manager.

try {         $mng = new mongodb\driver\manager("mongodb://username:password@localhost:27017/db");         $userid = '1234';         $retval = $mng->findandmodify(         array("userid" => $userid), // searchquery         array('$set' => array('active_time' => "kkk")) // updatequery         );         $command = new mongodb\driver\command($retval);         $cursor = $manager->executecommand('db.online', $command); } catch (mongodb\driver\exception\exception $e) {     $filename = basename(__file__);     echo "the $filename script has experienced error.\n";      echo "it failed following exception:\n";     echo "exception:", $e->getmessage(), "\n";     echo "in file:", $e->getfile(), "\n";     echo "on line:", $e->getline(), "\n";        } 

it shows error

fatal error: uncaught error: call undefined method mongodb\driver\manager::findandmodify()

in line

$retval = $mng->findandmodify(  array("userid" => $userid), // searchquery  array('$set' => array('active_time' => "kkk")) // updatequery  ); 

how possible? please me?

i got answer. change findandmodify update. modified code shown below.

$bulk->update(  array("userid" => '1234'), // searchquery  array('$set' => array('active_time' => "kkk")) // updatequery  );   $mng->executebulkwrite("browser.online", $bulk);   if(!empty($mng)) {     echo "success";     } else {         echo "not";     } 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -