Avi Kapuya
Avi Kapuya

Reputation: 1040

MongoDB findAndModify, is there an implementation in PHP for that?

I looked for findAndModify semantics in PHP but couldn't find any, would be happy to get reference / examples for this functionality.

Upvotes: 3

Views: 2169

Answers (2)

Karptonite
Karptonite

Reputation: 1632

For those still looking for this--This has now been implemented. http://php.net/manual/en/mongocollection.findandmodify.php

Upvotes: 1

Russell
Russell

Reputation: 12439

Here's the JIRA issue for the fact that it's missing from the PHP driver, which includes a workaround:

It's a database command, you can do:

$db->command(array("findandmodify" => "collectionName", "query" => ...));

See http://www.mongodb.org/display/DOCS/findandmodify+Command for details.

Upvotes: 4

Related Questions