PHP MongoDB, update document without erasing the rest -


i'm trying update mongo document, using php , update() function. however, when this, replaces whole document value wanted update. how can fix this?

the code have written now: http://twaddlr.com/view/73 (scroll down "update" function. it's database wrapper i'm writting site)

the key use $set in update, e.g. instead of (sorry using javascript syntax here, not sure exact php driver syntax):

db.my_collection.update({hello: "world"}, {foo: "bar"}) 

you do

db.my_collection.update({hello: "world"}, {$set: {foo: "bar"}}) 

if use $set, properties specify updated, whole document not replaced.

you can read more in documentation, here: http://www.mongodb.org/display/docs/updating#updating-modifieroperations

edit: looking @ code, in addrow method. same thing in update.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -