开发者

Suppress generation of _id on insert via PHP mongoDB driver on a capped collection

I have a capped collection witho开发者_JAVA技巧ut an _id index and I don't need the _id at all, but the PHP mongo driver always adds an _id on insert.

It is possible to suppress the automatic generation of an _id with the mongo shell

How can I supress the _id on insert with PHP?


You cannot get rid of _id , but you can overwrite it. So you can insert 1 column data into _id field.

eg.

$myCollection->insert(array("_id" => 2000, "data" => "someData));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜