Question

I want this:

SELECT i.inmueble_nombre, a.arrendatario_nombre, a.arrendatario_email, c.contrato_fecha_ini, c.contrato_fecha_fin
FROM zf_inmuebles i, zf_arrendatarios a, zf_contratos c
WHERE c.contrato_estado =  'ALta'
AND i.inmueble_id = c.zf_inmuebles_inmueble_id
AND a.arrendatario_id = c.zf_arrendatarios_arrendatario_id

In a dataprovider for a Clistview, how can I do it?

Was it helpful?

Solution

One simple option is to use a CSqlDataProvider. Basicaly, you just set the query and the count, and the data provider will return an array (with your selected columns as keys) for each list item.

OTHER TIPS

Try this code.

In controller.

    $sql = "SELECT i.inmueble_nombre, a.arrendatario_nombre, a.arrendatario_email, c.contrato_fecha_ini, c.contrato_fecha_fin
    FROM zf_inmuebles i, zf_arrendatarios a, zf_contratos c
    WHERE c.contrato_estado =  'ALta'
    AND i.inmueble_id = c.zf_inmuebles_inmueble_id
    AND a.arrendatario_id = c.zf_arrendatarios_arrendatario_id";

    $dataProvider=new CSqlDataProvider($sql,array(
    'pagination'=>array(
    'pageSize'=> '10', //no of record per page here
    ),);
$this->render('VIEW_NAME', array('dataProvider'=>$dataProvider));

In VIEW_FILE

$this->widget('zii.widgets.CListView',

            array(
                      'dataProvider'=>$dataProvider,
                      'ajaxUpdate'=>true,
                      'columns'=>array(
                      array('header'=>'Inmueble Nombre','name'=>'inmueble_nombre'),  
                      array('header'=>'Arrendatario Nombre','name'=>'arrendatario_nombre'), 

),
)); 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top