Hi there!
how can i make a cactivedataprovider of the following line?
$models = Hotel::model()->findAllByPk($pkArray);
thanks a lot!
Hi there!
how can i make a cactivedataprovider of the following line?
$models = Hotel::model()->findAllByPk($pkArray);
thanks a lot!
This should work:
$provider = new CActiveDataProvider(‘Hotel’);
$provider->setData($models);
or modify the following:
$dataProvider=new CActiveDataProvider('Post', array(
'criteria'=>array(
'condition'=>'status=1',
'order'=>'create_time DESC',
'with'=>array('author'),
),
'pagination'=>array(
'pageSize'=>20,
),
));
yesssss thanks
oh and i am just wondering, what’s the best way to pass an array of pk’s to a cdbcriteria? can it be done without a foreach loop?
Create a CDbCriteria first, and use $criteria->addInCondition(‘id’,$values). You can then pass this to the data provider