mongoDB curd操作
1 <?php 2 3 $mongo = new MongoClient("mongodb://127.0.0.1:2222/admin:admin"); 4 5 $collection=$mongo->rrs->content; 6 7 /* 数据库插入 */ 8 $content = array( 9 'title'=>'title', 10 'author'=>'jacson', 11 'url'=>'http://www.cnblogs.com', 12 ); 13 $collection->insert($content); 14 15 /* 数据库查询 */ 16 $colle = $collection->find(array('title'=>'title')); 17 foreach ($colle as $key => $val) { 18 var_dump($val); 19 }; 20 21 /* 数据库更新 */ 22 $where = array('title'=>'title'); 23 $set = array('name'=>'admin');//如果表中没有name,则会自省添加name参数 24 $collection->update($where,array( 25 '$set'=>$set, 26 )); 27 28 /* 数据库删除 */ 29 $collection->remove(array( 30 'title'=>'this is anthor title', 31 )); 32 33 ?>