How to upgrade the PHP7 operation MongoDB Method Introduction

Source: Internet
Author: User
Tags mongodb driver
This article is to share with you about how to upgrade PHP7 operation MongoDB Method Introduction, the content is very reference value, hope can help the need for small partners.

Objective

There are many users who use Php+mongodb because MongoDB is convenient for storing unstructured data. In PHP5 and before, the official provided two extensions, Mongo and MongoDB , among them, the Mongo classes based on a number of MongoClient core classes to operate, encapsulation is very convenient, so basically will choose the Mongo extension.

But with PHP5 upgrading to PHP7, the official no longer supports Mongo extensions, only MongoDB, and PHP7 's performance gains are huge. So that people can not give up, so how to replace Mongo into MongoDB becomes a problem to be solved urgently. MongoDB introduces namespaces, but the functional encapsulation is very poor, if it is not to use the native extension, it almost means to write the native Mongo statement. This idea is contrary to the ORM simplification IO of the syntax problems brought about by the DB operation and focus on the logic optimization idea.

In this case, MONGODB official could not help, in order to facilitate the use, increase market share, the introduction of the MongoDB-based expansion of the library:

MongoDB Driver

If the original driver is used, the approximate syntax is as follows:

<?phpuse mongodb\driver\manager;use mongodb\driver\bulkwrite;use mongodb\driver\writeconcern;use MongoDB\Driver \query;use Mongodb\driver\command;class MongoDB {

Related recommendations:

Introduction to User usage in Yii2 (code attached)

Development of composer extensions and application of Laravel framework

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.