php - Yii Display data from dataprovider of 2 models -


how can display "arrendatario_nombre" using dataprovider in clistview

$dataprovidercontratos = new cactivedataprovider(zfcontratos::model(), array(             'keyattribute'=>'zf_contrato_id',             'criteria'=>array(                 'order' => 'contrato_fecha_ini',                 'select' => 't.*, arr.arrendatario_nombre arrendatario_nombre',                 'join' => 'left join zf_arrendatarios arr on arr.arrendatario_id = t.zf_arrendatarios_arrendatario_id',                 'condition'=>'zf_inmuebles_inmueble_id=-1',             ),         )); 

i tried:

$data->arrendatario_nombre 

thanks!

you can use yii relations purpose, http://www.yiiframework.com/doc/guide/1.1/en/database.arr#declaring-relationship

in zfcontratos model file use following , can call $data->arrendatario_nombre

public function relations() {     return array(         'arrendatario_nombre' => array(self::belongs_to, 'zf_arrendatarios', 'zf_arrendatarios_arrendatario_id'),         );     } 

once declared in model file can use $data->arrendatario_nombre , in other place place load zfcontratos model


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -