zoukankan      html  css  js  c++  java
  • get record count of form datasource

    modified class : SysQuery

    public client server static Integer countTotal(QueryRun _queryRun,int num = 1)//add datasource num
    {
        container c = SysQuery::countPrim(_queryRun.pack(false),num);

        return conpeek(c,1);
    }

    private server static container countPrim(container _queryPack,int num = 1)//add datasource num
    {
        Query                   countQuery;
        QueryRun                countQueryRun;
        QueryBuildDataSource    qbds;
        QueryBuildFieldList     qbfl;
        Common                  common;
        Integer                 counter;
        Integer                 loops;
        ;
        countQueryRun   = new QueryRun(_queryPack);
        countQuery      = countQueryRun.query();
        qbds            = countQuery.dataSourceNo(num);//put datasource num
        qbds.update(false);
        qbds.sortClear();
        qbfl = qbds.fields();
        qbfl.dynamic(false);
        qbfl.clearFieldList();
        //if (countQuery.dataSourceCount() == 1)  //remark this
            qbds.addSelectionField(fieldnum(Common,RecId),SelectionField::Count);

        countQueryRun   = new QueryRun(countQuery);

        while (countQueryRun.next())
        {
            common  = countQueryRun.get(countQuery.dataSourceNo(num).table());//put datasource num
            counter += common.RecId;
            loops++;
        }

        return [counter,loops];
    }

    usage:

        Query query;
        QueryRun queryRun;
        ;
        query =new query();

        query.addDataSource(tablenum(CustTable)).addRange(fieldnum(CustTable,AccountNum)).value(queryRange('000001','000008'));


        queryRun = new QueryRun(query);
        info(strfmt('%1',SysQuery::countTotal(queryRun)));

  • 相关阅读:
    越狱第三季开播了
    永远成长的苹果树
    最强最短的武侠小说
    买房和租房15年后的巨大差别[好文转载]
    秋凉了,大家别加班了,早回吧:)
    dedecms dede_archives表中arcrank和ismake两个字段的理解
    asp.net c#读取word 文档的方法
    css实现不固定长度圆角按钮,兼容所有浏览器
    js keyup、keypress和keydown事件 详解
    android中使用webview缓存网页
  • 原文地址:https://www.cnblogs.com/lingdanglfw/p/1963596.html
Copyright © 2011-2022 走看看