problem with ar, getting a related table attribute

Hi, I have this:

$areasUsuarioActivo = UsuarioArea::model()->with('area')->find(


                array(


                    'condition' => 'usuario_id = :usuario_id',


                    'select' => 'area.texto',


                    'params' => array('usuario_id' => Usuario::getActiveUserId())


                )


);

and yii give me this error:

>>Active record "Usuarioarea" esta intentando de seleccionar una columna inválida "area.texto". Nota: >>La columna puede existir en la base o ser una expresion con alias.

If I comment the select the trace shows:

>> Querying SQL: SELECT t.usuario_id AS t0_c0, t.area_id AS t0_c1,

>> t.id AS t0_c2, area.id AS t1_c0, area.texto AS t1_c1,

>> area.orden AS t1_c2, area.publica AS t1_c3 FROM usuarioarea

>> t LEFT OUTER JOIN area area ON (t.area_id=area.id) WHERE

>> (usuario_id = :usuario_id). Bind with parameter :usuario_id=‘3’

It seems that all is ok, area.texto seems to be there, does someone see something wrong?

pd: if in the select I replace area.texto with area.id there is no error!

ok, this did it:


    $areasUsuarioActivo = UsuarioArea::model()->findall(

                    array(

                        'with'=>array(

                            'area'=>array('select'=>'id,texto')

                        ),

                        //'select' => '',

                        'condition' => 'usuario_id = :usuario_id',

                        'params' => array('usuario_id' => Usuario::getActiveUserId())

                    )

    );

How can I get only the “area” attributes and not the “UsuarioArea” attributes, if I use the select => ‘’ it doesnt work

I think this is the best alternative:

at Usuario, declare a MANY_MANY relationship to Area, with AreaUsuario as the relationship table.




areas => array(self::MANY_MANY, "Area", "AreaUsuario(usuario_id, area_id)");



Then load the Usuario model




$usuario = Usuario::model()->findByPk(Usuario::getActiveUserId());



Then load Areas related to Usuario as below:




$areas = $usuario->areas;