3

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?

1
  • 1
    can someone enlighten me why this post was voted down?
    – AJ Naidas
    Commented Jun 5, 2013 at 14:49

1 Answer 1

12

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.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.