exists
:需要一个操作数,该操作数必须是代表子查询 yii\db\Query 的一个实例, 它将会构建一个 EXISTS (sub-query)
表达式。
CxxxCxxx::find()->select(['cc.ch_id'])->alias('cc')->where(['exists', (new yii\db\Query())->select(['rcc.c_id'])->from('{{%rel_XXX_XXX_class}} as rcc')->where('cc.c_id = rcc.c_id')])->orderBy('cc.ch_id')->column();
new query
$query = (new \yii\db\Query())
->from('user')
->limit(10)
->indexBy('id')
->all();