Create MongoDB ObjectID from date in the past using PHP driver

后端 未结 3 899
别那么骄傲
别那么骄傲 2020-12-17 02:14

I have to import a lot of data into MongoDB from MySQL and I\'d like to use the timestamp from the ObjectID instead of storing it in a separate key/value (as it is in the ex

3条回答
  •  离开以前
    2020-12-17 02:38

    Right now, the PHP driver has no built in functionality for this, the __set_state() that the other answer mentioned is only for being able to session-deserialize the ID and doesn't allow you to create it through the specific components.

    You will have to do the following to automatically create an ID:

    
    

提交回复
热议问题