Cgridview from the other model

Hello guys i need your help,

i want to show in my model view the personal detail and children that they have

like this

<h1>View Lksa  <?php echo $model->lksa_name; ?></h1>

<?php $this->widget('zii.widgets.CDetailView', array(

























		    'label'=>'Buku Rekening',


		    'value'=>CHtml::link('view', '#', array('onclick'=>'$("#bukuRekening").dialog("open"); return false;',))),



)); ?>


$this->beginWidget('zii.widgets.jui.CJuiDialog', array(



        'title'=>'Buku Rekening',






    echo CHtml::image(Yii::app()->request->baseUrl . '/images/accountPicture/' . CHtml::encode($model->picture), CHtml::encode($model->picture)

,array('height'=>'100%', 'width'=>'100%'));



//this cgridview to show all of the children that live in model above and their status 1

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















)); ?>

and in model i try to put

public function relations()



		return array(





public function findAnak($id)


		// Warning: Please modify the following code to remove attributes that

		// should not be searched.

		$criteria=new CDbCriteria;

		 $criteria->condition = " = childData.lksa_data_id and = ".$id;



		//$criteria->params = array(':id'=>$id);


		return new CActiveDataProvider($this, array(




and i got this error

CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'childData.lksa_data_id' in 'where clause'. The SQL statement executed was: SELECT `t`.`id` AS `t0_c0`, `t`.`year` AS `t0_c1`, `t`.`lksa_code` AS `t0_c2`, `t`.`lksa_name` AS `t0_c3`, `t`.`address` AS `t0_c4`, `t`.`regency_id` AS `t0_c5`, `t`.`email` AS `t0_c6`, `t`.`leader` AS `t0_c7`, `t`.`ownership_status_id` AS `t0_c8`, `t`.`contact_person` AS `t0_c9`, `t`.`handphone_number` AS `t0_c10`, `t`.`notarial_deed` AS `t0_c11`, `t`.`npwp` AS `t0_c12`, `t`.`siop` AS `t0_c13`, `t`.`bank_account` AS `t0_c14`, `t`.`name_account` AS `t0_c15`, `t`.`account_number` AS `t0_c16`, `t`.`picture` AS `t0_c17` FROM `lksa_data` `t` WHERE ( = childData.lksa_data_id and = 1) LIMIT 10 

can you give me solution?please

I’m not sure but it could be that the same name of the relation and your table childData could cause the problem.

Try to rename the relation.

$criteria->condition = " = childData.lksa_data_id and = ".$id;

change to

 $criteria->condition = " = ".$id;

if use “with” it’s no need to compare id from 2 table…


sorry :rolleyes: i know it’s from me…

and u don’t have field lksa_data_id in table childdata…

maybe it’s lksadata_id or lksa_id…