创建文档:
$db->collection->insert($content);
// $newDocID = ???
我正在尝试获取新文档的 ID。如何?谢谢。
最佳答案
根据the docs您传递给 insert
的数组将使用 _id
字段进行修改:
$db->collection->insert($content);
$newDocID = $content['_id'];
https://stackoverflow.com/questions/4525556/