123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace loyalsoft;
- include __DIR__ . '/main.php';
- //var_dump(__DIR__);
- echoLine("phpver: " . PHP_VERSION . PHP_EOL);
- echoLine("tsDay:" . totalDays());
- //SelfChecker::CheckAll();
- //
- //set_time_limit(15); # 设置执行超时时间
- //
- //$cfg = config::Inst();
- //$mu = new MongoUtil();
- //$manager = $mu->conn($cfg->mongodb);
- //if ($manager === false) {
- // CLog::err("MongoDB连接异常!");
- //}
- // select
- $collection = 'test.ylsj2019taptap';
- $filter = ['key' => ['$regex' => '.*-g$']];
- $opt = MongoUtil::QueryOptionBuilder()->limit(3)->projection(['key' => 1, 'name' => '$value.baseInfo.name'])
- ->sort(["value.baseInfo.level" => -1]);
- $cursor = gMongo()->find($collection, $filter, $opt->GetOption());
- if (false === $cursor) {
- exit("查询失败");
- }
- //foreach ($cursor as $document) {
- // var_dump($document);
- //}
- // insert
- //$collection = "foo.bar";
- //$addArr = ['name' => "王刚1", 'age' => 37];
- //CLog::Assert("insert", gMongo()->insert($collection, $addArr), "插入数据");
- //
- //// delete
- //$collection = "foo.bar";
- //$deletFilter = ['name' => "王刚1"];
- //echoLine("删除" . gMongo()->delete($collection, $deletFilter) . "条");
- // update
- $collection = "foo.bar";
- $updateFilter = ['Name' => "王刚(wanggangzero@qq.com)1"];
- $updateArr = ['Name' => "王刚(wanggangzero@qq.com)1", 'Age' => 37, '性别' => "男", '爱好' => '女'];
- echoLine("修改" . gMongo()->update($collection, $updateFilter, $updateArr, true, false));
- //
- echoLine("---");
|