[MongoDB] MongoDB and php,mongodbphp
Installing MongoDB PHP extensions on Windows
Download Address https://s3.amazonaws.com/drivers.mongodb.org/php/index.html
Find the corresponding PHP version of the DLL file, download Php_mongo.dll, put in the PHP installation directory in the EXT directory, modify the php.ini, add a extension=php_mongo.dll, did not find support PHP7 DLL
Get Mongoclient object, new out
Gets the database object db, through the database properties of the Mongoclient object, $MongoClient database name
Gets the collection collection, by the collection property of the DB object, $db the collection name
Creates a collection that invokes the CreateCollection () method of the DB object,
Call the Find () method of the collection object, query the data, $collection->find ()
Calls the update () method of the collection object, updates the data, $collection->update ($condition, $data);
Call the Insert () method of the collection object, insert the data, $collection->insert ($data);
Php//Connect to MongoDB$mongoClient=Newmongoclient ();//Select a database$db=$mongoClient-test;//Get Collection$collection=$db-users;//Update document$condition=Array();$condition["id"]=1;$data=Array();$data[' Name ']= ' Wangwu ';$data[' Age ']= ' 11 ';$collection->update ($condition,$data);//Insert 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);//Querying documents$users=$collection-find ();foreach($users as $k=$v) { Print_r($v);}?>
http://www.bkjia.com/PHPjc/1122396.html www.bkjia.com true http://www.bkjia.com/PHPjc/1122396.html techarticle [MongoDB] MongoDB with php,mongodbphp install MongoDB PHP extension download address on Windows https://s3.amazonaws.com/drivers.mongodb.org/php /index.html find the corresponding PHP version of the DLL file, ...