MANY_MANY Yii 查询限制为相关记录列表


MANY_MANY Yii query limiting to list of related records

>我有一个 Yii 应用程序,其中包含具有MANY_MANY关系的产品和兴趣。显然,这些映射具有以下关系:

            'interests'=>array(self::MANY_MANY, 'Interest', 'interest_product_assignment(product_id,interest_id)'),

我希望使用 CDbCriteria 查询产品,如下所示:

$products = Product::model()->with('interests')->findAll($criteria);

此查询工作正常。我需要扩展它以将其限制为仅具有存储在数组中的 id 的某些兴趣。我相信这应该是可能的,比如:

    $products = Product::model()->with(
        'interests',
        array('condition' => {not_sure_what_to_put_here})
    )->findAll($criteria);

我不确定如何完成上述查询,并且已经寻找了一段时间。不是我找不到任何东西,而是我无法理解我挖到的任何东西。

任何人都可以发现如何完成此查询吗?

编辑

我对特尔文的建议进行了尝试:

    $products = Product::model()->with(
        'interests',
        array('condition' => "interests_interests.interest_id IN ($selectedInterestsString)")
    )->findAll($criteria);

不向查询添加"IN"语句。

提供的ID数组:

$array_ids =    array('1','24','350','4609', ....)    
$array_ids_str = '"' . implode('","', array_values($array_ids)) . '"';
$products = Product::model()->with(array(
        'interests'=> array('condition' => "interest_id_column IN ($array_ids_str)"
    )))->findAll($criteria);