开发者

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

开发者 https://www.devze.com 2023-04-01 18:19 出处:网络
I have a capped collection witho开发者_JAVA技巧ut an _id index and I don\'t need the _id at all,

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

精彩评论

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

关注公众号