我希望這個Sql命令轉換成yii cactivedataprovider格式,這樣我就可以用這個標準來提供數據提供者。如何將此查詢轉換爲yii查詢?
SELECT *
FROM (
SELECT (
CASE WHEN product_name LIKE '%nokia%'
THEN 1
ELSE 0
END +
CASE WHEN product_name LIKE '%lumia%'
THEN 1
ELSE 0
END +
CASE WHEN product_name LIKE '%800%'
THEN 1
ELSE 0
END
) AS numMatches, product_name
FROM Production
) AS t
WHERE numMatches >0
ORDER BY numMatches DESC
您是否嘗試過' CSqlDataProvider' http://www.yiiframework.com/doc/api/1.1/CSqlDataProvider?或者這不是一個選擇? – topher 2013-02-13 07:17:53
我嚴格需要CActiveDataProvider,因爲它將傳遞給小部件。 – user1532043 2013-02-13 07:52:45