简体   繁体   English

在yii2 mongodb中找到具有相同属性和超过2个值的位置

[英]find where with same attribute and more than 2 values in yii2 mongodb

I can count it with one ObjectId as shown below.我可以用一个 ObjectId 来计算它,如下所示。

public function count_typesA() {
    $list = Shops::findAll(['typeid'=>new MongoDB\BSON\ObjectId("57eb8395b5ea6a14c00075d2")]);
    return count($list);
}

I have to count all the typeid with 57ea5880b5ea6a0650002785 and 57eb8395b5ea6a14c00075d2 .我必须用57ea5880b5ea6a065000278557eb8395b5ea6a14c00075d2计算所有 typeid 。 (Same attribute typeid with different values) How to do it? (相同的属性typeid具有不同的值)怎么做?

Something like this could help:这样的事情可能会有所帮助:

public function count_typesA() {
    $list = Shops::findAll(['typeid'=> [
        new MongoDB\BSON\ObjectId("57eb8395b5ea6a14c00075d2"),
        new MongoDB\BSON\ObjectId("57ea5880b5ea6a0650002785")
      ]
    ]);
    return count($list);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM