Yii SQL到CActiveDataProvider

I need help from Yii experts, I have a SQL query

SELECT p.name , p.price FROM products as p, prod_cat as pc WHERE pc.id_pr  =  p.id_pr AND pc.id_cat in (SELECT id_cat FROM prod_cat where id_pr=<myid>)

I need to convert this to CActiveDataProvider in Yii. something like this

            $dataProvider2=new CActiveDataProvider('Products',array(
                        'criteria' => array(
                             ...                                      
                        ),

                ));

I have 3 Tables : Products, Categories and Prod_cat (connection between two others). I need to find others products from the same category of item that i provide ().

I would create a view in your database (using that query). Then make a model in Yii based on that view. Creating an activedataprovider will then be easy.

http://en.wikipedia.org/wiki/View_(database)

One Idea is to use an model with relations. http://www.yiiframework.com/doc/guide/1.1/en/database.arr

The other way is to use DAO, but it does not work with CActiveDataProvider