多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] # 学堂作答记录从mongo新集合获取数据 # https://tower.im/teams/46865/todos/27502/ ## 学堂WEB通信协议 本协议包含: - 服务器向mongo请求统计数据协议 - 客户端向mongo请求心急数据协议 - 客户端向服务器请求网页相关内容协议 https://tower.im/teams/46865/documents/4408/ ## MongoDB类 http://php.net/manual/zh/class.mongodb.php 技术文档: http://www.mongoing.com/docs/index.html ## 练习记录 ``` /** @var EMongoClient $mongo */ $mongo = Yii::app()->mongodb; $collection = $mongo->selectCollection(WK::XT_EXER_RECORD_COLLECTION); $args['begin'] = 1548172800; $args['end'] = 1550764800; $res = $collection->aggregate( array( '$match' => array( 'uid' => 474598, 'date' => array( '$gte' => new MongoDate($args['begin']), '$lte' => new MongoDate($args['end']), ) ), ), array( '$project' => array( '_id' => 1, 'exid' => 1, 'eid' => 1, 'tags' => 1, 'score' => 1, 'total' => 1, 'scoreRate' => 1, 'date' => 1, ), ), array( '$sort' => array( 'date' => -1, // 日期倒序 ) ) ); ``` ## ## 接口: http://t.wmxuetang.com/index.php?r=croom/exam/GetSortTagsAndAlias&answerExamID=1913303&examID=140399&_t=t ``` { "tags": [ { "tagid": "53605", "name": "集合的基本运算", "rate": 0, "rate_all": 57 }, { "tagid": "53612", "name": "函数的概念、要素、表示法", "rate": 0, "rate_all": 26 }, { "tagid": "53620", "name": "对数函数", "rate": 0, "rate_all": 16 }, { "tagid": "53627", "name": "函数的综合应用", "rate": 0, "rate_all": 6 }, { "tagid": "53629", "name": "导数的概念和运算", "rate": 0, "rate_all": 13 }, { "tagid": "53631", "name": "导数的综合应用(2)", "rate": 0, "rate_all": 6 }, { "tagid": "53634", "name": "简单几何体", "rate": 0, "rate_all": 18 }, { "tagid": "53635", "name": "直观图与三视图", "rate": 0, "rate_all": 41 }, { "tagid": "53646", "name": "平面向量的数量积", "rate": 0, "rate_all": 12 }, { "tagid": "53651", "name": "空间向量的基本概念和运算", "rate": 0, "rate_all": 9 }, { "tagid": "53654", "name": "向量的综合应用", "rate": 0, "rate_all": 9 }, { "tagid": "53662", "name": "圆的位置关系", "rate": 0, "rate_all": 13 }, { "tagid": "53667", "name": "椭圆(2)", "rate": 0, "rate_all": 6 }, { "tagid": "53670", "name": "抛物线(2)", "rate": 0, "rate_all": 8 }, { "tagid": "53672", "name": "双曲线(1)", "rate": 0, "rate_all": 17 }, { "tagid": "53675", "name": "圆锥曲线综合问题", "rate": 0, "rate_all": 12 }, { "tagid": "53683", "name": "三角恒等变换", "rate": 100, "rate_all": 38 }, { "tagid": "53686", "name": "解三角形(2)", "rate": 0, "rate_all": 25 }, { "tagid": "53694", "name": "等比数列", "rate": 0, "rate_all": 10 }, { "tagid": "53709", "name": "统计抽样和图表", "rate": 0, "rate_all": 11 }, { "tagid": "53712", "name": "变量的相关性与统计案例", "rate": 0, "rate_all": 11 }, { "tagid": "53716", "name": "概率的综合应用", "rate": 100, "rate_all": 24 }, { "tagid": "53727", "name": "复数的四则运算", "rate": 0, "rate_all": 36 }, { "tagid": "53731", "name": "二项式定理", "rate": 100, "rate_all": 34 }, { "tagid": "67494", "name": "选考内容", "rate": 0, "rate_all": 5 } ], "main_tags": [ { "tagid": "53601", "name": "集合与常用逻辑用语", "rate": 0, "rate_all": 57 }, { "tagid": "53610", "name": "函数与导数", "rate": 0, "rate_all": 11 }, { "tagid": "53632", "name": "立体几何和向量", "rate": 0, "rate_all": 15 }, { "tagid": "53655", "name": "解析几何", "rate": 0, "rate_all": 10 }, { "tagid": "53676", "name": "三角函数和解三角形", "rate": 50, "rate_all": 31 }, { "tagid": "53688", "name": "数列和不等式", "rate": 0, "rate_all": 10 }, { "tagid": "53702", "name": "算法、统计、概率", "rate": 17, "rate_all": 13 }, { "tagid": "53721", "name": "推理、复数、计数", "rate": 50, "rate_all": 35 }, { "tagid": "67491", "name": "扩展部分", "rate": 0, "rate_all": 5 } ], "alias": [ { "id": 300, "name": "单选题", "rate": 25, "rate_all": 41 }, { "id": 303, "name": "填空题", "rate": 0, "rate_all": 16 }, { "id": 308, "name": "综合题", "rate": 0, "rate_all": 11 } ], "score": { "total": 160, "score": 15, "score_obj": 0, "score_avg": 26.42, "score_top": 129, "beat_rate": 0.43, "rate": 50 }, "$diffPer": { "easy": 17.39, "moderate": 56.52, "difficult": 26.09 }, "num": { "unRight": 20, "right": 3 }, "unselfNum": 11 } ``` *D:\wamp\www\xue.test\xuetang\protected\modules\croom\controllers\ExamController.php*