插入操作 查看返回值
// $result = $mongoObj->insert($data); //insert插入成功返回结果array(6) { ["connectionId"]=> int(36862) ["n"]=> int(0) ["syncMillis"]=> int(0) ["writtenTo"]=> NULL ["err"]=> NULL ["ok"]=> float(1) }
1:更新成功后,返回array(7) { ["connectionId"]=> int(36864) ["updatedExisting"]=> bool(true) ["n"]=> int(1) ["syncMillis"]=> int(0) ["writtenTo"]=> NULL ["err"]=> NULL ["ok"]=> float(1) }
//2:失败后array(7) { ["connectionId"]=> int(36864) ["updatedExisting"]=> bool(false) ["n"]=> int(0) ["syncMillis"]=> int(0) ["writtenTo"]=> NULL ["err"]=> NULL ["ok"]=> float(1) }
//1:删除成功操作后,返回的结果 array(6) { ["connectionId"]=> int(36865) ["n"]=> int(1) ["syncMillis"]=> int(0) ["writtenTo"]=> NULL ["err"]=> NULL ["ok"]=> float(1) }
//2:删除失败后,返回的结果 array(6) { ["connectionId"]=> int(36865) ["n"]=> int(0) ["syncMillis"]=> int(0) ["writtenTo"]=> NULL ["err"]=> NULL ["ok"]=> float(1) }
//返回取出的值
//array(4) { ["_id"]=> object(MongoId)#7 (1) { ["$id"]=> string(24) "58a3ed5a6e0ef78c27000030" } ["name"]=> string(9) "zhangxiao" ["age"]=> string(2) "19" ["sex"]=> string(3) "nan" }
本文出自 “json在php中的使用” 博客,请务必保留此出处http://zhaozhangxiao.blog.51cto.com/10609825/1898059
mongo操作 insert / findOne remove update 返回的值判断
原文:http://zhaozhangxiao.blog.51cto.com/10609825/1898059