Join query issue

Hi all,

I have used join query i got 2 fields only displayed on view insteed of 4 fields, i have mentioned my code below i have been facing this issue 3 days please any one help me.

My model code : (Mapmerchantid.php)

function getData() {

    $sql = "SELECT a.uid,mid,dbaname,sponsor_bank from pd_user_mid_mapping a LEFT JOIN pd_user b on a.uid = b.uid";





    $data = Yii::app()->db


    ->createCommand($sql)


    ->queryAll();


    return $data;

}

My controller code:(MapmerchantidController.php)

public function actionAdmin()

{


        $model=new Mapmerchantid('search');


        


        $data_combine =  Mapmerchantid::model()->getData();


        //print_r($model);


        $model->unsetAttributes();  // clear any default values


        if(isset($_GET['Mapmerchantid']))


                $model->attributes=$_GET['Mapmerchantid'];





        $this->render('admin',array(


                'model'=>$model,'datacombine'=>$data_combine


        ));


}

My view code :(admin.php)

<?php $this->widget(‘zii.widgets.grid.CGridView’, array(

'id'=&gt;'mapmerchantid-grid',


'dataProvider'=&gt;&#036;model-&gt;search(),


'filter'=&gt;&#036;model,


'columns'=&gt;array( 


	'uid',


            'mid',


        array(            


        'name'=&gt;'dbaname',


        'value'=&gt;'&#036;data_combine-&gt;dbaname',


        ),





      array(            


        'name'=&gt;'sponsor_bank',


        'value'=&gt;'&#036;data_combine-&gt;sponsor_bank',


        ),		array(


                'class'=&gt;'CButtonColumn',


	),


),

)); ?>


I got the out put on the grid for UID and MID, dbaname and sponsor_bank will be displayed as plank here with i have attached my screen pls any one help me.

Hi,

Why do not you try to use the model’s relation?

http://www.yiiframework.com/doc/guide/1.1/en/database.arr#declaring-relationship

So, you can use in the CGridView ‘relationName.sponsor_bank’.