Method of operating MongoDB database in PHP program

Method of operating MongoDB database in PHP program

<?php error_reporting(7); $conn = new Mongo(); $db = $conn->PHPDataBase; $collection = $db->PHPCollection; /*—————————– * delete *—————————– $collection->remove(array(“name” => “xixi111”)); */ /*—————————— * Insert *—————————— for($i = 0; $i <= 50; $i++) { $data = array(“name” => “xixi”.$i,”email” => “673048143_”.$i.”@qq.com”, “age” => $i*1+20); $collection->insert($data); } */ /*——————————- * Find *——————————– $res = $collection->find(array(“age” => array(‘$gt’ => 25,’$lt’ => 40)), array(“name” => true)); foreach($res as $v) { print_r($v); } */ /*——————————- * Update *——————————– $collection->update(array(“age” =>22),array(‘$set’ => array(“name” => “demoxixi”))); */ ?> Complete the installation of MongoDB Complete the extension of PHP to MongoDB and restart apache Start the MongoDB service, just like mysql. Then you can operate MongoDB with PHP. Here are some notes from my own study today: First of all, you must have a clear understanding of the concept. Additions, deletions, revisions and inquiries of news. The first is news addition, news title, news author, and news content. Then read the news. The data in MongoDB is read out and read through PHP. The interface here is written in HTML language, this is the same. A traditional relational database generally consists of three levels: database, table, and record. MongoDB is composed of three levels: database, collection, and document. MongoDB…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索