0
插入禁止代_id我有沒有_id索引加蓋收集,我不需要_id可言, 但PHP蒙戈司機總是添加在插入時_id。上通過PHP mongoBD司機封頂集合
It is possible to suppress the automatic generation of an _id with the mongo shell
我如何可以禁止用PHP在插入的_id?
插入禁止代_id我有沒有_id索引加蓋收集,我不需要_id可言, 但PHP蒙戈司機總是添加在插入時_id。上通過PHP mongoBD司機封頂集合
It is possible to suppress the automatic generation of an _id with the mongo shell
我如何可以禁止用PHP在插入的_id?
你不能擺脫_id,但你可以覆蓋它。 因此,您可以將1列數據插入到_id字段中。
例如。
$myCollection->insert(array("_id" => 2000, "data" => "someData));
好吧,我會用_id作爲時間戳/新MongoDate()THX :) – Thomas
但是你必須要小心的是,_id值是唯一的,因爲它是唯一索引。見http://my.safaribooksonline.com/book/databases/9781449306779/implementation-tips/i_sect12_d1e1208 – DhruvPathak
它是一個封頂集合,所以_id不必是唯一的 - 在這種情況下,它不是n索引 – Thomas