Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call to undefined method MongoDB::update()

when using the update statement via PHP means am getting the error.

Call to undefined method MongoDB::update()

I'm using the mongo-php-driver driver for connecting the MongoDB and PHP

My Code

$result = $this->mongo_db->update('table_name',array('user_type'=>"D"),array('$set'=>array('account_balance'=>0)),array('upsert'=>true));

My MongoDB reference link is https://docs.mongodb.com/manual/reference/method/db.collection.update/

like image 932
Siva Avatar asked Aug 24 '26 14:08

Siva


1 Answers

Hi am using updateMany instead of update. Its working fine for me.

$result = $this->mongo_db->updateMany('table_name',array('user_type'=>"D"),array('$set'=>array('account_balance'=>0)),array('upsert'=>true));
like image 121
Siva Avatar answered Aug 26 '26 04:08

Siva



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!