Cdbcriteria And Related Column

Hi, in the controller i have this piece of code:

$criteria = new CDbCriteria;



                             'select' => false,



                             [b]'select' => array('userandbuildings.users_id'),[/b]


                     $criteria->together = true;


$criteria->addCondition("constructions.building_idbuilding IS NOT NULL", "AND");

$sort = new EDTSort('Building', array('idbuilding','name','city','email'));             

             $sort->defaultOrder = 'idbuilding ASC';


             $pagination = new EDTPagination();


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

                'criteria'      => $criteria,

                'pagination'    => $pagination,

                'sort'          => $sort,


And…In widget DataGridView array Columns:


[b]Yii report this error:

PHP Notice: Trying to get property of non-object [/b]


Tnx in advice.

anyone help me?

What is relation beetwen this tables ? Maybe userandbuildings is an array and you cant display array in one column.

And what if user dont have any buildings ? Than you try to display something that dont exist.

You can try

'value'=>'$data->userandbuildings ? $data->userandbuildings->users_id : ""'

Tnx for reply mirunho, you hint is correct but does not solve the problem.

relation in model:

'userandbuildings' => array(self::HAS_MANY, 'Userandbuilding', 'building_idbuilding'),

The Building have always one creator user!

$data->userandbuildings have no value in array but exist!

Your relation is has_many so You try to display an array and its not possible to do this. You can display something like


Great you solved my problem!

Thanks so much