CActiveDataProvider wierd behavior

I have this lines of code…

        echo '<pre>';



…it does show the correct output when "die()" is executed, but, when I remove the "die()" it throws

"Trying to get property of non-object" on the exact same line on "print_r"

Here is my Model relation

public function relations()


		return array(

			'ProductCategory'=>array(self::HAS_ONE, 'ProductCategory', 'prd_cat_id'),

			'ProductType'=>array(self::HAS_ONE, 'ProductType', 'prd_typ_id'),

			'ProductStyle'=>array(self::HAS_ONE, 'ProductStyle', 'prd_sty_id'),




public function actionIndex()


		$dataProvider=new CActiveDataProvider('Product', array(









You are missing related data in the relation.

You need to test to see if $model->property is set (has related data) or not.

Could you please explain this with more details? This is the same problem that I have.

Exactly my problem.