多表关联 搜索时多表字段重名,怎么办?

多表关联 搜索时多表字段重名.怎么办?

第一次尝试,CDbCommand 无法执行 SQL 语句: SQLSTATE[23000]: Integrity constraint violation: 1052 Column ‘type’ in where clause is ambiguous.,代码如下:

$model = Featured::model()->with(array(‘company’,‘member’,‘inqpay’));

                if (isset($_GET['Featured']))


            $model->attributes = $_GET['Featured'];


            $model->setAttribute('type', $type);

第二次尝试,不起作用,显示所有类型的数据,代码如下:

$model->setAttribute(’{{Featured}}.type’, $type);

第三次尝试(

CActiveDataProvider and its behaviors do not have a method or closure named "search". )代码如下:

$condition = ‘’;

    if(isset($_GET['type']))


    {


        $condition = 'type='.intval($_GET['type']);


    }


    $model=new CActiveDataProvider('Featured', array(


        'criteria'=>array(


            'condition'=>$condition,


            'with'=>array('company','member','inqpay'),


        ),


    ));

解决了,代码为方法一,

另外在模型中,方法search()中,更改

$criteria->compare(‘t.type’, $this->type);

嗯。看错误说明,应该是在 model里面修改。。。