新建文件夹
- 新建文件夹 2019-04-30 已签到连续签到2天,获得了10个金钱
- 新建文件夹 评论了教程 Yii2 Mongodb 生成递增id的方法
上面两种方法我都做了测试:
// 上面的方法可能有问题 改为下方二种方法 // 方法一:(对应原作者) // $update = ['?inc' => ['id' => 1]]; // $query = ['name' => static::collectionName()]; // $command = [ // 'findandmodify' => 'ids', 'update' => $update, // 'query' => $query, 'new' => true, 'upsert' => true // ]; // $result = current($coll->database->createCommand($command)->execute()->toArray()); // 方法二:(对应kero) $result = $coll->findandmodify( ['name' => 'ids'], ['?inc' => ['id' => 1]], ['upsert' => true, 'fields' => 'id', 'new' => true] ); return $result['_id'];
- 新建文件夹 2019-04-29 已签到连续签到1天,获得了5个金钱