How to Relation Through Search

Hi,

How to Show Records Relation Through Search,

I have table relation below,

class Deposit extends CActiveRecord

{

public $auction_id;

public function relations()

{


	return array(


        'charge'     =>array(self::HAS_ONE,    'Charge',      'deposit_id'), 


        'bid'=>array(self::HAS_MANY,'Bid',array('bid_id'=>'id'),'through'=>'charge'),		


		


		);


}

}

I Have Relation Charge table to bid table I write that Relation Through,

I write Search function,

public function search()

{

$criteria->compare(‘bid.auction_id’,$this->auction_id,true,‘OR’);

}

And then i write view page to view the record bid table auction and also view the deposit table record So i wrote,

$this->widget(‘bootstrap.widgets.TbGridView’, array(

'id'=>'deposit-grid',


'dataProvider'=>$model->search(),


'filter'=>$model,


'ajaxUpdate'=>false,


'columns'=>array(	

‘id’,

	'user_id',

array(

	'header'=>'Auction Id',


	'name'=>'auction_id',


	'value'=>'$data->bid->auction_id'),

Id,User_id in Deposit table record but no records show in Bid table …Please Tell me Solution ?

Your not displaying the data in the GridView properly





$this->widget('bootstrap.widgets.TbGridView', array(

	'id'=>'deposit-grid',

	'dataProvider'=>$model->search(),

	'filter'=>$model,

	'ajaxUpdate'=>false,

	'columns'=>array(

		'id',

		'user_id',

		array(

			'header'=>'Auction Id',

			'name'=>'auction_id',

			'type'=>'raw',

			'value'=>function($data) {

			    return	$data->bid->auction_id;

			}),

	)));



Hi Thanx for ur reply,

Now also i cant get records from bid table,Please tell me model codings are correct.

Try to switch the columns up

Change




'bid'=>array(self::HAS_MANY,'Bid',array('bid_id'=>'id'),'through'=>'charge'), 

To




'bid'=>array(self::HAS_MANY,'Bid',array('id'=>'bid_id'),'through'=>'charge'), 

If that doesn’t work contact me on Skype, my username is petschephp