使用的是yii2的 yii2tech\embedded 这个mongodb的扩展,想问一下,如何使用内嵌查询 就是将mongodb这个语句 db.getCollection('outbound').find({'fullfillmentData.is_cancel_order':1}) 转化成基于 use yii2tech\embedded\mongodb\ActiveRecord;的AR的内嵌查询。
希望有人能解答,谢谢啦
1.建立model
<?php /** * FecShop file. * * @link http://www.fecshop.com/ * @copyright Copyright (c) 2016 FecShop Software LLC * @license http://www.fecshop.com/license/ */ namespace fecshop\models\mysqldb\cms; use yii\db\ActiveRecord; /** * @author Terry Zhao <2358269014@qq.com> * @since 1.0 */ class Article extends ActiveRecord { public static function tableName() { return 'article'; } }
2.查询
Article::find()->where(['xx.xx' => 'value'])->all();
in查询
Article::find()->where([ 'xx.xx' => [ '$in' => ['value1','value2'] ] ])->all();