[MongoDB] mongodb and php, mongodbphp_PHP tutorial

Source: Internet
Author: User
Tags install mongodb mongoclient
[MongoDB] mongodb, php, and mongodbphp. Find the corresponding php version of dll file, [MongoDB] mongodb and php, mongodbphp

Install mongodb php extension on windows

Https://s3.amazonaws.com/drivers.mongodb.org/php/index.html

Find the corresponding php version dll file, download php_cmd.dll, put it in the ext directory under the php installation directory, modify php. ini, and add an extension = php_cmd.dll. no php7-supported dll is found.

Get the publish client object, new

Obtain the database object database, and use the database attribute of the restore client object. for example, $ export client-> database name

Get the collection, and use the collection attribute of the db object, $ db-> set name

Create a collection and call the createCollection () method of the db object,

Call the find () method of the collection object to query data, $ collection-> find ()

Call the update () method of the collection object to update data, $ collection-> update ($ condition, $ data );

Call the insert () method of the collection object to insert data, $ collection-> insert ($ data );

 Test; // Obtain the collection $ collection = $ db-> users; // update the document $ condition = array (); $ condition ["id"] = 1; $ data = array (); $ data ['name'] = "wangwu"; $ data ['age'] = "11"; $ collection-> update ($ condition, $ data); // Insert the document $ data = array (); $ data ['id'] = 4; $ data ['name'] = "haha "; $ data ['age'] = "11"; $ collection-> insert ($ data); // delete a document $ condition = array (); $ condition ['id'] = 2; $ collection-> remove ($ condition); // query the document $ users = $ collection-> find (); foreach ($ users as $ k = >V v) {print_r ($ v) ;}?>

Mongodb and php, mongodb installed on windows mongodb php extension https://s3.amazonaws.com/drivers.mongodb.org/php/index.html find the corresponding php version of the dll file ,...

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.