zoukankan      html  css  js  c++  java
  • 程序记录1(添加字段)

    bool DBCenter::setUserTableTest()
    {
        //修改user表
        UseTable(m_userTable);
        for (int i = 999; i < 1000; ++i)
        {
            char condJson[JSON_LENGTH_MIN] = {0};
            sprintf(condJson, "{%s:%d}", m_userStruct._id.c_str(), i);
            char secJson[JSON_LENGTH_MIN] = {0};
            sprintf(secJson, "{%s:1}", m_userStruct.aids[0].c_str());
            char *Res = NULL;
            bool isExit;
            char *errMessage = NULL;
            m_mongo->FindOneData(m_ns.c_str(), condJson, secJson, &Res, &isExit, m_errMsg);
            if (!isExit)
            {
                continue;
            }
            if(!strstr(Res, m_userStruct.aids[0].c_str()))//没有角色
                continue;
            //获取角色的个数
            using namespace boost::property_tree;
            ptree proot,//树根
                pchild,//子树
                pnode;//节点
            stringstream stream(Res);
            //将流放入树根
            read_json<ptree>(stream,proot);
            pchild=proot.get_child(m_userStruct.aids[0].c_str());
            for (int i = 0; i < pchild.size(); i++)
            {
                char setJson[JSON_LENGTH_MIN] = {0};
                sprintf(setJson, "{$set:{'%s.%d.%s':0}}", m_userStruct.aids[0].c_str(), i, m_userStruct.aids[4].c_str());
                if (!m_mongo->UpdataData(m_ns.c_str(), condJson, setJson))
                {
                    return false;
                }
            }
        }
        return true;
    }
  • 相关阅读:
    C#连接Oracle数据库的连接字符串
    Oracle
    SQL 计算某月有多少天
    七牛开发者文档中心
    ocrstyle
    Linux的sys接口和proc接口创建
    BusHelper
    MeiTuanLocateCity
    Shop
    Win10预览版10162全新安装及激活全过程图解
  • 原文地址:https://www.cnblogs.com/zzyoucan/p/3654543.html
Copyright © 2011-2022 走看看