如何使用$ In operatore Query builder symfony2 + MongoDb

时间:2016-08-06 07:47:22

标签: mongodb symfony

您好我有以下查询我想通过检查mongoDb中的数组(存储为集合)中存在的特定Id来获取数据,如下所示:     //代金券收藏:

 "byLedgers": [
 [
   "57a578b7518459d1008b4567",
   "57a30cd25184590a018b4567"
    ]
 ]
So I am running query in my repository as following:
$getAllVouchers =     $dm->createQueryBuilder('EduAccountBundle:VoucherGeneration');
        $getAllVouchers->field('isDeleted')->Equals(false);
        $getAllVouchers->addOr($getAllVouchers->expr()->field('byLedgers')->Equals($id)); //Here how to use $in instead Equals
        $getAllVouchers->addAnd($getAllVouchers->expr()->field('financialYear')->Equals($currentFinancialYear));
$resultTo = $getAllVouchers->getQuery()->execute();

我得到0结果。我需要使用$ in而不是Equals。但不知道如何使用它。请帮忙 提前致谢

0 个答案:

没有答案