php MongoDB操作类
MongoDB操作类 仿写CI的,带测试实例。**mongo_config.php**```{.php}lt;?php$config[quot;hostquot;] = quot;localhostquot;;$config[quot;userquot;] = quot;quot;;$config[quot;passquot;] = quot;quot;;$config[quot;portquot;] = 27017;$con
仿写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 */
- 上一篇:PHP二分查找实例
- 下一篇:php实现简单的留言板程序
精彩图集
精彩文章