title: How do I make a sql request in codeigniter
body: <h2>How do I make a sql request in codeigniter</h2>
  
  <p>Codeigniter request</p>
  
  <pre><code>  $this-&gt;db-&gt;select('visites.id, persons.fio, sum(services.cena)');
      $this-&gt;db-&gt;from('visites');
      $this-&gt;db-&gt;join('persons', 'visites.clients = persons.id', 'inner');
      $this-&gt;db-&gt;join('draft', 'draft.vis = visites.id', 'inner');
      $this-&gt;db-&gt;join('services', 'draft.ser = services.id', 'inner');
      $this-&gt;db-&gt;group_by(array("visites.id, persons.fio")); 
  
          if($_POST['length'] != -1)
          $this-&gt;db-&gt;limit($_POST['length'], $_POST['start']);
          $query = $this-&gt;db-&gt;get();
          return $query-&gt;result();
  </code></pre>
  
  <h1>How to create correctly request?</h1>