<?php include "db.php"; $m = new MongoClient('mongodb://localhost:27017'); $db = $m->mongo; //选择或者创建数据库 $db->user->insert(array("id"=>"1","name"=>"wangpan")); //创建表并添加数据; $user=$db->user->find(array("id"=>"1")); p($user); $db = $m->mongo; $table=$db->user; $table->insert(array("id"=>"2","name"=>"guojuan2")); $table->insert(array("id"=>"3","name"=>"guojuan3")); $table->insert(array("id"=>"4","name"=>"guojuan4")); 删除数据库 $db1 = $m->wangpan; $db1->drop(); p($m->listDBs());//查看所有数据库 $db =$m->mongo; $table=$db->user; p($table->count()); p($table->insert(array("name"=>"guojuan4"))); p($table->findOne(array("name"=>"guojuan4"))); p($table->remove(array("name"=>"guojuan4"))); p($table->update(array("name"=>"guojuan5","id"=>"44")));? $ob = array('id'=>'3','name'=>'wanghaoran'); p($table->insert($ob)); p($table->find()); ?>