In siteController
I write query and pass array of dataProvider
to index.php
to display contain in table form. In index.php
I want to display member name
instead of memberID
. For that I have write inner query and which is successfully run on command prompt successfully.Here I am not able to print first name
instead of 'member id
'
public function actionIndex()
{
$query = new \yii\db\Query;
$query->select(['member.firstName',
'complaint.practiceCode','complaint.id',
'complaint.description','member.firstName'])
->from(['complaint'])
->innerJoin(['member','complaint.memberID = member.id'])
->groupBy(['complaint.id'])
->where(['complaint.deleted' => 'N']);
$query->createCommand();
Here I have pass data by creating $dataProvider4
but I am not able to set value of firstName
instead of memberID
.
$dataProvider4= new ActiveDataProvider([
'query' => $query,
'pagination' => false,
]);
return $this->render('index', [
'dataProvider4'=>$dataProvider4]);
<?= GridView::widget([
'dataProvider'=>$dataProvider4,
'summary'=>'Total'.' <b>'.$complaintModel.'</b> '.'Complaints',
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'practiceCode',
// 'memberID',
'description',
'status',
],
]); ?>
I have pass data through the dataProvider.