Can anybody tell me what is the possible solution for the following code. It is giving me error that class CArrayDataProvider is not found.Although I have included the class on the top of the code:
use yii\framework\web\CArrayDataProvider;
Code:
$connection=Yii::app()->db;
$user = Yii::app()->user->getId();
$rows= $connection->createCommand()->select('*')->from('tbl_project_user_assignment')->
where(‘user_id=:id’,array(’:id’=>Yii::app()->user->getId()))->queryAll();
//$rows=$command->execute();
foreach($rows as $row){
//process each item here
$pid=$row['project_id'];
//echo $pid;
$rows2= Yii::app()->db->createCommand()->select('*')->from('tbl_project')->
where(‘id=:pid’,array(’:pid’=>$pid))->queryAll();
//$rows2=$command2->execute();
$arr=array();
$i=0;
foreach($rows2 as $row) {
$arr=array(
$i=>array(
'id'=>$row['id'],
'name'=>$row['name'],
'description'=>$row['description'],
'create_time'=>$row['create_time'],
'create_user_id'=>$row['create_user_id'],
'update_time'=>$row['update_time'],
'update_user_id'=>$row['update_user_id']
),
);
}
}
$dataProvider=new CArrayDataProvider([
'allModels' => $arr,
'pagination' => [
'pageSize' => 10,
],
'sort' => [
'attributes' => ['id', 'name'],
],
]);
$this->render('index',array(
'dataProvider'=>$dataProvider,
));