如何在codeigniter中发出sql请求

时间:2016-02-12 10:29:32

标签: php mysql codeigniter sum

如何在codeigniter

中发出sql请求

Codeigniter请求

  $this->db->select('visites.id, persons.fio, sum(services.cena)');
    $this->db->from('visites');
    $this->db->join('persons', 'visites.clients = persons.id', 'inner');
    $this->db->join('draft', 'draft.vis = visites.id', 'inner');
    $this->db->join('services', 'draft.ser = services.id', 'inner');
    $this->db->group_by(array("visites.id, persons.fio")); 

        if($_POST['length'] != -1)
        $this->db->limit($_POST['length'], $_POST['start']);
        $query = $this->db->get();
        return $query->result();

如何正确创建请求?

2 个答案:

答案 0 :(得分:0)

您的意思是"传递数据以查看" ?

控制器

$data['list'] = $this->your_model->fn();
$this->load->view("your_view",$data);

查看

<?php print_r($list); ?>

答案 1 :(得分:0)

{{1}}