Home  >  Article  >  Backend Development  >  MongoDBDriverCursor gets result set in associative array form?

MongoDBDriverCursor gets result set in associative array form?

WBOY
WBOYOriginal
2016-10-10 11:56:27827browse

During the upgrade process of php7, since the old mongo.so extension is no longer supported, we have no choice but to use mongodb.so. The cursor objects between the two are very different. The old version of the cursor object returns an _id as the key after iteraor_to_array. Associative array, can the new version only return a numerical index array? Is there any way to solve it?

Reply content:

During the upgrade process of php7, since the old mongo.so extension is no longer supported, we have no choice but to use mongodb.so. The cursor objects between the two are very different. The old version of the cursor object returns an _id as the key after iteraor_to_array. Associative array, can the new version only return a numerical index array? Is there any way to solve it?

When using the MongoDBDriverBulkWrite() class to perform an insert operation, an object with oid=uniq_random_words will be returned. This should be its key, right? When performing a query operation, the queried data will also come out with the field
oid. This can be used as the key in the associative array you mentioned, right? ? I'm also learning mongodb, sorry if you verify that this is not what I said

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn