The content shared with you in this article is an introduction to how to upgrade PHP7 to operate MongoDB. The content is of great reference value and I hope it can help friends in need.
There are many users usingPHP MongoDBbecauseMongoDBis very convenient for storing unstructured data. InPHP5and before, two official extensions are provided,Mongo
andMongoDB
, whereMongo
is an extension toMongoClient
It is very convenient to operate on several core classes based categories, so theMongo
extension is basically chosen.
But with the upgrade ofPHP5toPHP7, the official no longer supports theMongoextension, onlyMongoDB, and The performance improvement ofPHP7is so huge that people cannot let it go, so how to replaceMongowithMongoDBhas become an urgent problem to be solved.MongoDBintroduces namespace, but the function encapsulation is very poor. If you have to use native extensions, it almost means writing nativeMongostatements. This idea goes against the idea ofORMsimplifying the syntax problems caused by DBIO
operations and focusing on logic optimization.
Under this situation, MongoDB officials couldn't help it. In order to facilitate use and increase market share, they launched a library based on MongoDB extension:
If you use the original driver, the general syntax is as follows:
Copy after login
Related recommendations:
Usage introduction of user in yii2 (with code)
The above is the detailed content of Introduction to how to upgrade PHP7 to operate MongoDB. For more information, please follow other related articles on the PHP Chinese website!