使用CDBcriteria在php yii中编写连接查询

时间:2013-07-26 10:00:31

标签: php yii

你好我很新的PHP yii我有以下查询

select d.* from customer_service_provider csp inner join (select id_customers from customer_devices cd where id_devices=2) as c on csp.id_customers=c.id_customers inner join user_devices ud on ud.id_users = csp.id_users inner join devices d on d.id = ud.id_devices 

如何使用CDBcriteria

写入php yii

1 个答案:

答案 0 :(得分:1)

你无法使用$ criteria和CActiveDataProvider从'customer_service_provider'获取'devices'(d。*)。

因为CActiveDataProvider需要一个模型来将查询结果转换为该模型的对象列表,但在这种情况下,您必须传递模型'customer_service_provider'类。

抱歉我的英语..