博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
php mongo client
阅读量:7045 次
发布时间:2019-06-28

本文共 1372 字,大约阅读时间需要 4 分钟。

hot3.png

​$conn = new MongoClient("mongodb://192.168.1.239:27017");

$db = $conn->test;              // 选择数据库blog

     $collection = $db->menu;

 

/*$menu = Menu::find()->asArray()->getAll();

foreach($menu as $v)

{             // 新增 

$collection->insert($v);  

}*/

 

   

//$newdata = array('$set' => array("email" => "test@test.com"));              // 修改

//$collection->update(array("name" => "caleng"), $newdata);  

   

//$collection->remove(array('name'=>'caleng'), array("justOne" => true));      // 删除

  

$cursor = $collection->find();          // 查找 

// 迭代显示文档标题

foreach ($cursor as $document) {

dump($document);

   

//$user = $collection->findOne(array('name' => 'caleng'), array('name','email'));      // 查找一条

//var_dump($user);  

$conn->close();  

exit;

//$memcache = new Memcache; //创建一个memcache对象

//$memcache->connect('192.168.1.239', 11212) or die ("Could not connect"); //连接Memcached服务器

//$memcache->addServer('192.168.1.239', 11212);

 

$mem_conf = array(

array('host'=>'192.168.1.239', 'port'=>'11211'),

array('host'=>'192.168.1.239', 'port'=>'11212')

);

 

$memcache = new Memcache();

foreach ($mem_conf as $v) {

$memcache->addServer($v['host'],$v['port']);

}

 

$menu = Menu::find()->asArray()->getAll();

foreach($menu as $v)

{

$memcache->set('menu_'.$v['mid'], json_encode($v));

}

//$memcache->set('key4', 'test4'); //设置一个变量到内存中,名称是key 值是test

//$get_value = $memcache->get('key4'); //从内存中取出key的值

//echo $get_value;

 

转载于:https://my.oschina.net/sharesuiyue/blog/788980

你可能感兴趣的文章
FIR.im:iOS 8.1.3 “各路助手挺尸”、“封杀一切助手”的背后
查看>>
我的友情链接
查看>>
找出一个数组中唯一没有成对出现的两个数
查看>>
《Android开发从零开始》——3.第一个Android程序
查看>>
在Windows下ip地址无法解析,使用ipconfig /registerdns可以恢复正常
查看>>
我的友情链接
查看>>
Android ViewPager 设置不滑动
查看>>
laravel中HTML::style类出错解决方法
查看>>
合并排序最差效率递推式的精确解
查看>>
IOS中Foreach使用不当会引起NSGenericException
查看>>
聊聊UIView
查看>>
mysql主从
查看>>
Linux系统下转换文件编码的方法
查看>>
Excle百万数据量 导出
查看>>
云盘参数和性能测试方法
查看>>
Web前端——链接和表格使用规范
查看>>
2.6.18 32位环境 src.rpm包的使用
查看>>
Windows服务创建及安装
查看>>
Python27+Opencv3 VideoCapture FALSE问题记录
查看>>
如何在 Linux 系统查询机器最近重启时间
查看>>