0

我在产品和兴趣之间有很多关系。我正在尝试选择 5 种归因于特定兴趣的产品。到目前为止我的代码不起作用,我找不到路由原因。

我的关系:

public function relations()
{
    return array(
        'interests'=>array(self::MANY_MANY, 'Interest', 'interest_product_assignment(product_id,interest_id)'),

我在 Product 模型中的函数用于返回产品:

public function getProducts($id){
    return $products = Product::model()->with('interests')->find(
        array(
            'condition' => "interests.interest_id = $id",
            'limit' => 5
        )
    );
}

当我使用该功能时,会显示错误:

"Column not found: 1054 Unknown column 'interests.interest_id' "

运行的查询甚至不会尝试连接这两个表。

谁能发现这个问题的原因?我怀疑这是基本的,但我看不到。

4

0 回答 0