How do I update all documents in mongodb PHP

mongodb, php

Solution

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.

Problem

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?

Original source