mongo操作 insert / findOne remove update 返回的值判斷

插入操作 查看返回值

// $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" }


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章