DataTables in Codeigniter (display million rows of data)

DataTables in Codeigniter (display million rows of data)

PatrickOfreneoPatrickOfreneo Posts: 5Questions: 3Answers: 0

I created a DataTable in codeigniter and it's already working with small amount of data but I want to run the project with 1 Million rows of data. Unfortunately, it is not working with this huge amount of data.

What should I add/change in my code below? I'm using codeigniter, oracle database and odbc driver

Thank you!

Here's my JavaScript

    <script>

 $('#user-list').DataTable({
    
  "processing": true,
 
 
    dom: 'Bfrtip',
        buttons: [
            'excel'
        ],
          
        "ajax": {
            url : "<?php echo base_url(); ?>Reports/get_User,
            type : 'GET'
        },
         

         "aoColumns": [
          { "data": "ID" },
          { "data": "FirstName" },  
          { "data": "LastName" },
          { "data": "Address"},
          { "data": "Email" },
  
                      
            ]
      
    });

</script>

Here's my html

<table id="user-list" class="table table-bordered table-striped table-hover">
        <thead>
            <tr>
                <th>ID</th>
                <th>First name</th>
                <th>Last name</th>
                <th>Address</th>
                <th>Email</th>
            </tr>
        </thead>
    </table>

Here's my controller

 public function get_User()
   {
      $draw = intval($this->input->get("draw"));
      $start = intval($this->input->get("start"));
      $length = intval($this->input->get("length"));
    

      $query =$this->db->query("SELECT * FROM users"); 

      
      $data = [];



      foreach($query->result() as $r) {
           $data[] = array(
                $r-ID
                $r-FirstName,
                $r-LastName,
                $r-Address,
            $r-Email,
                $r_tab[] = $r


           );
      }

      $result = array(
               "draw" => $draw,
                 "recordsTotal" => $query->num_rows(),
                 "recordsFiltered" => $query->num_rows(),
                 "data" => $data,
                  "data" =>  $r_tab

            );
      echo json_encode($result);
      exit();
    }

Answers

This discussion has been closed.