Reputation: 2821
I try to delete document in mongodb using php, I it fails and I get a waring:
Warning: MongoCollection::remove() expects parameter 2 to be boolean, array given
$mongo = new Mongo();
$db = $mongo->test;
$collection = $db->subscribers;
$collection->remove(array( 'LISTID' => 49));
Could you please tell me what causes an error? I phpinfo() shows:
mongo
MongoDB Support enabled
Version 1.0.4+
Directive Local Value Master Value
mongo.allow_persistent On On
mongo.auto_reconnect On On
mongo.chunk_size 262144 262144
mongo.cmd $ $
mongo.default_host localhost localhost
mongo.default_port 27017 27017
mongo.utf8 1 1
It's strange, the documentation say the function looks like:
public mixed MongoCollection::remove ( array $criteria [, array $options = array() ] )
Upvotes: 3
Views: 3913
Reputation: 164733
You appear to be using a very old version. From the manual
1.0.5 Changed second parameter to an array of options. Pre-1.0.5, the second parameter was a boolean indicating the "justOne" option and there was no safe option.
Either upgrade or change your code to
$collection->remove(array('LISTID' => 49), false);
Upvotes: 2
Reputation: 14187
You need to specify the remove options:
$collection->remove(array('type' => 94), array("justOne" => true));
for more info, see the online manual
Upvotes: 3