栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 数据库 > MongoDB

mongodb怎样分库

MongoDB 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

mongodb怎样分库

1、建立一个新的mongodb库。

2、把当前的mongodb集合改为比如 log_data为log_data_201904062230。

3、把log_data_201904062230备份到新库中。

4、在获取数据的地方再连接新库的log_data_201904062230集合展示数据。

代码示例如下:

$where = array();
if( $product_id )
{
    $where['lq_product_id'] = $product_id;
}
if( $qrcode )
{
    $where['lq_qrcode'] = $qrcode;
   //$where['lq_qrcode'] ="75906.DRMWH.A.13_50.N";
}
if( $lq_user)
{
   $where['lq_user'] = $lq_user;
}
$page_list_num = 100;
$cls_log = cls_app:: get_cls( 'log' ); 
$cls_log->set_collection( 'log_data' );
$list = $cls_log->get_list( $page, $page_list_num, $where, array( 'lq_time'=> -1 ) );
//去历史里拉数据
$cls_log_his = new cls_log ( 'bullfrog_history' );
$cls_log_his -> set_db( 'log' );
$cls_log_his -> set_collection( 'log_data_201904062230' );
$list_his = $cls_log_his->get_list( $page, $page_list_num, $where, array( 'lq_time'=> -1 ) );
$list_all = array_merge( $list, $list_his );

python学习网,大量的免费MongoDB入门教程,欢迎在线学习!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/14249.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号