dongzhao3040 2011-05-16 13:10
浏览 42
已采纳

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 ().

  • 写回答

2条回答 默认 最新

  • duanbei8904 2011-05-16 18:01
    关注

    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)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料