Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of PHP and MongoDB

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "what is the use of PHP and MongoDB". The content is simple and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn this article "what is the use of PHP and MongoDB?"

A brief introduction to MongoDB

MongoDB (named from "humongous") is a scalable, high-performance, open-source, schema-free, document-oriented database that combines the advantages of document database, key-value pair storage and relational database. Official site: http://www.mongodb.org/ Magi MongoDB Features:

Document-oriented storage (JSON-like data schema is simple and powerful)

Dynamic query

Full index support, extended to internal objects and embedded arrays

Query record analysis

Fast, on-the-spot update

Efficient storage of binary large objects (such as photos and videos)

Replication and failover support

Auto-Sharding automatic sharding supports cloud-level scalability

MapReduce supports complex aggregation

Business support, training and consulting

Second, install MongoDB

It is very easy to install MongoDB, just download the compressed package to extract the run command, download address: http://www.mongodb.org/downloads, this article is the windows platform, MongoDB run command: > bin/mongod. Tip: first of all, you need to create a folder to store data. The default directory for storing data in MongoDB is / data/db/ (or c:\ data\ db). Of course, you can also change it to a different directory. Just specify-- dbpath parameter, eg:

> bin/mongod-- dbpath=d:\ mgdata\ db

Install the MongoDB PHP extension

Download the PHP extension: http://github.com/mongodb/mongo-php-driver/downloads according to your own version of PHP, prompt:

1. VC6 is suitable for Apache and VC9 is suitable for IIS

2. Thread safe is suitable for PHP in module operation mode, and Non-thread safe is suitable for CGI operation mode.

Modify php.ini, add: extension=php_mongo.dll, restart the Web server.

4. Related examples of PHP testing and MongoDB

1. Connect to the Mongo server

The copy code is as follows:

The copy code is as follows:

2. Specify the database and dataset name (table name)

The copy code is as follows:

The copy code is as follows:

3 、 CRUD

The copy code is as follows:

The code is as follows:

4. Close the connection

The above is all the content of this article "what is the use of PHP and MongoDB?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report