MongoDB操作PHP类

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

仿写CI的,带测试实例。

mongo_config.php

<?php

$config["host"] = "localhost";
$config["user"] = "";
$config["pass"] = "";
$config["port"] = 27017;

$config["dbname"]  = "test";
$config['persist'] = TRUE;
$config['persist_key'] = 'ci_mongo_persist';

/*End of mongo_config.php*/

MyMongoDemo.php

<?php
include_once("MyMongo.php");

$conn = new MyMongo();
//删除所有记录
$conn->delete_all("blog");

//插入第一条记录
$value = array("name" => "小明", "age" => 25, "addr" => array("country" => "中国", "province" => "广西", "city" => "桂林"));
$conn->insert("blog", $value);

var_dump($conn->select(array("name", "age"))->get("blog"));

var_dump($conn->get("blog"));

/* End of MyMongoDemo.php */