此代码工作正常:
$criteria = new CDbCriteria;
$criteria->compare('id', 1);
$dataProvider = new CActiveDataProvider('User', array('criteria'=>$criteria));
foreach ($dataProvider->getData() as $value) var_dump($value->id);
但是当我在创建 CActiveDataProvider 实例后更改条件时,这不起作用:
$criteria = new CDbCriteria;
$criteria->compare('id', 1);
$dataProvider = new CActiveDataProvider('User', array('criteria'=>$criteria));
$criteria->compare('id', 2);
foreach ($dataProvider->getData() as $value) var_dump($value->id);
此返回空!为什么是这样?