I am setting up a cronjob to update the field views_15 on all documents from collection query.
This is what I had, that should have worked:
$update = array(
'$set' => array (
'views_15' => 0
)
);
$db->queries->update(array(), $update, array('multi' => true));
Also it works for a specific query!
So what should I use instead of array(), from the < query > parameter to select all documents?
Replace 'multi' with 'multiple' in the options to your update command:
$db->queries->update(array(), $update, array('multiple' => true));
See http://php.net/manual/en/mongocollection.update.php for all the valid update options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With