使用url Codeigniter

时间:2016-07-13 06:09:13

标签: php codeigniter url

我在变量$ data Model中遇到问题。 我将显示系统屏幕的结果。

This is the screen

我的模特:

public function get_aqui($id=NULL){
    if ($id !=NULL):
        $this->db->select('*');
        $this->db->from('financeiroaquiler as f');
        $this->db->join('aluguel as a', 'f.aluguel_id_alug = a.id_alug');
        $this->db->join('usuarios as u', 'u.id_usu = a.inquilino_id_inqui');
        $this->db->join('apartamento as d', 'd.id_apart = a.apartamento_id_apart');
        $this->db->where('a.id_alug', $id);
        $query = $this->db->get('');

        if ($query-> num_rows ()> 0) {
            foreach ($query-> result_array () as $row) {
                $data [] = $row;
                var_dump($row);
            }
        }
        $query-> free_result();
       return $data;
    else:
        set_msg('msgerro', 'error', 'erro');
    endif;
}

我的控制器:

 public function pagos($id){       
    $this->sindico->get_aqui($id);
    set_tema('titulo', 'Lista de Pagos Aquillers');
    set_tema('conteudo',  load_modulo('aquiler', 'pagos'));
    load_template();
}

我的观点:

 <?php
             $dados['album'] = $this->sindico->get_aqui();
             if (count($dados['album'])){
             foreach ($dados['album'] as $linha) {
                 echo '<tr>';
                 printf('<td>%s / %s</td>', ($list['id_alug']) ?: '/', ($linha->nome_usu));
                 printf('<td>%s</td>', $linha->data_pagamento);
                 printf('<td>%s</td>', "Bs" . $linha->valor_pagamento);
                 printf('<td>%s</td>', $linha->status_pagamento);
                 printf('<td class="text-center">%s</td>', '<div class="btn-group"><button data-toggle="dropdown" class="btn btn-xs dropdown-toggle"  data-original-title="" title="">Action<span class="caret"></span></button><ul class="dropdown-menu pull-right"><li><a href="editar/' . $linha->id_finan . '">Edit</a></li><li><a href="excluir/' . $linha->id_finan . '">Delete</a></li>');
                 echo '</tr>';
             }}
             ?>

看看get_aqui函数。变量$ data出现问题的地方。

1 个答案:

答案 0 :(得分:0)

<强>模态

 public function get_aqui($id=NULL){
        if ($id !=NULL):
            $this->db->select('*');
            $this->db->from('financeiroaquiler as f');
            $this->db->join('aluguel as a', 'f.aluguel_id_alug = a.id_alug');
            $this->db->join('usuarios as u', 'u.id_usu = a.inquilino_id_inqui');
            $this->db->join('apartamento as d', 'd.id_apart = a.apartamento_id_apart');
            $this->db->where('a.id_alug', $id);
           return $query = $this->db->get('')->result();

        else:
            set_msg('msgerro', 'error', 'erro');
        endif;
    }

我的控制器:

public function pagos($id){       
    $data['result']=$this->sindico->get_aqui($id);
    set_tema('titulo', 'Lista de Pagos Aquillers');
    set_tema('conteudo',  load_modulo('aquiler', 'pagos'));
    load_template();
}

现在你可以使用$ result-&gt;通过传递

在视图文件中 table_coloum_name
 $this->load->view('**view_file_name**',$data['result']); in conroller