这将如何转换为yii CActiveDataProvider结构?!
SELECT t1.*
FROM data t1
WHERE t1.date= (SELECT MAX(t2.date)
FROM data t2
WHERE t2.fromNumber = t1.fromNumber)
由于
答案 0 :(得分:3)
尝试此代码:未经测试。请检查。
希望您已为此表创建模型。在Model_name
$dataProvider=new CActiveDataProvider('Model_name', array(
'criteria'=>array(
'condition'=>'t.date = (SELECT MAX(t2.date)
FROM data t2
WHERE t2.fromNumber = t1.fromNumber)'
)
)
);
这有效:
$dataProvider=new CActiveDataProvider('Data', array(
'criteria'=>array(
'condition'=>'t.date = (SELECT MAX(t2.date)
FROM data t2
WHERE t2.fromNumber = t.fromNumber)'),
));