jquery datatable serverside dans codeigniter ne fonctionne pas

J’ai essayé de combiner les données à l’aide de datables server dans codeigniter via ajax, mais j’obtiens le résultat d’erreur, comme ceci:

Une erreur est survenue dans la firebase database

Numéro d’erreur: 1096

Aucune table utilisée

SELECT * ORDER BY id_judul ASC LIMIT 2

Nom de fichier: models / Judul_model.php

Numéro de ligne: 88

modèle:

  'asc'); // default order private function _get_datatables_query() { $sql = "SELECT judul.id_judul, judul.judul_buku, judul.isbn, judul.penulis, judul.penerbit, judul.klasifikasi, judul.cover, judul.letak, /*jumlah total*/ IFNULL((SELECT COUNT(buku.id_buku) FROM buku WHERE buku.id_judul = judul.id_judul GROUP BY buku.id_judul),0) AS jumlah_total, /*jumlah ada*/ IFNULL((SELECT COUNT(buku.id_buku) FROM buku WHERE buku.id_judul = judul.id_judul AND buku.is_ada = 'y' GROUP BY buku.id_judul),0) AS jumlah_ada, /*jumlah keluar*/ IFNULL((SELECT COUNT(buku.id_buku) FROM buku WHERE buku.id_judul = judul.id_judul AND buku.is_ada = 'n' GROUP BY buku.id_judul),0) AS jumlah_dipinjam FROM judul GROUP BY judul.id_judul ORDER BY judul.id_judul DESC"; $this->db->query($sql); $i = 0; foreach ($this->column_search as $item) // loop column { if($_POST['search']['value']) // if datatable send POST for search { if($i===0) // first loop { $this->db->group_start(); // open bracket. query Where with OR clause better with bracket. because maybe can combine with other WHERE with AND. $this->db->like($item, $_POST['search']['value']); } else { $this->db->or_like($item, $_POST['search']['value']); } if(count($this->column_search) - 1 == $i) //last loop $this->db->group_end(); //close bracket } $i++; } if(isset($_POST['order'])) // here order processing { $this->db->order_by($this->column_order[$_POST['order']['0']['column']], $_POST['order']['0']['dir']); } else if(isset($this->order)) { $order = $this->order; $this->db->order_by(key($order), $order[key($order)]); } } function get_datatables() { $this->_get_datatables_query(); if($_POST['length'] != -1) $this->db->limit($_POST['length'], $_POST['start']); $query = $this->db->get(); return $query->result(); } function count_filtered() { $this->_get_datatables_query(); $query = $this->db->get(); return $query->num_rows(); } public function count_all() { $this->db->from($this->table); return $this->db->count_all_results(); } //////////////////////////////////// } 

manette :

 load->view('template',compact( 'main_view')); } //Harus Login terlebih dahulu protected function isLogin() { $isLogin = $this->session->userdata('is_login'); if(!$isLogin) { redirect(base_url()); } } //Datatable serverside public function ajax_list() { $level = $this->session->userdata('level'); $list = $this->judul->get_datatables(); $data = array(); $no = $_POST['start']; foreach ($list as $judul) { $no++; $row = array(); $row[] = $no; $row[] = $judul->isbn; $row[] = $judul->judul_buku; $row[] = $judul->penulis; $row[] = $judul->penerbit; $row[] = 'Total: '. $judul->jumlah_total != 0 ? anchor("buku/total/$judul->id_judul",$judul->jumlah_total) : $judul->jumlah_total. '
'. 'Ada : '. $judul->jumlah_ada != 0 ? anchor("buku/ada/$judul->id_judul",$judul->jumlah_ada) : $judul->jumlah_ada. '
'. 'Dipinjam : ' . $judul->jumlah_dipinjam != 0 ? anchor("buku/dipinjam/$judul->id_judul",$judul->jumlah_dipinjam) : $judul->jumlah_dipinjam; if($judul->cover) $row[] = 'cover).'" target="_blank">cover).'" style="border: 1px solid #aaaaaa; padding: 2px; width: 100px;" class="cover img-responsive" />'; else $row[] = ''; $row[] = $judul->letak ; if ($level === 'admin'): $row[] = form_open("buku/create").form_hidden('id_judul',$judul->id_judul).form_hidden('first_load',true).form_button(['type' => 'submit','content' => 'add', 'class' => 'btn btn-success waves-effect','data-toggle' => 'tooltip', 'data-placement' => 'right' ,'title' => 'Tambah Copy Buku']).form_close(); $row[] = anchor("judul/edit/$judul->id_judul",'edit', ['class' => 'btn btn-warning waves-effect','data-toggle' => 'tooltip', 'data-placement' => 'right' ,'title' => 'Edit']); $row[] = form_open("judul/delete/$judul->id_judul").form_hidden('id_judul',"$judul->id_judul").form_button(['type' => 'submit','content' => 'delete', 'class' => 'btn btn-danger waves-effect','data-toggle' => 'tooltip', 'data-placement' => 'right' ,'title' => 'Delete','onclick' => "return confirm('Anda yakin akan menghapus judul ini?')"]).form_close(); endif; $data[] = $row; } $output = array( "draw" => $_POST['draw'], "recordsTotal" => $this->judul->count_all(), "recordsFiltered" => $this->judul->count_filtered(), "data" => $data, ); //output to json format echo json_encode($output); } /////////////////////////////////////////////////////////// }

vue:

 session->userdata('is_login'); $level = $this->session->userdata('level'); ?>  load->view('_partial/flash_message') ?> 

BUKU

No ISBN Judul Penulis Penerbit Jumlah Copy Cover Letak Add Edit Delete
'btn btn-primary waves-effect','data-toggle' => 'tooltip', 'data-placement' => 'right' ,'title' => 'Tambah Judul']) ?>  
$(document).ready(function() { $('#serverside').DataTable({ "processing" : true, "serverSide" : true, "language": { "url": "adminbsb/plugins/jquery-datatable/Indonesian.json", searchPlaceholder: "No Anggota, No Induk, Nama" }, "lengthMenu": [ [5, 10, 25, -1], [5, 10, 25, "All"] ],"pageLength": 2, "order" : [], "ajax": { "url" : "", "type" : "POST" }, "columnDefs" : [ { "targets" : [0], "orderable":false, }, ], }); });

Aidez-moi, s’il vous plaît…

$this->db->query() n’est pas une fonction d’enregistrement active, elle devrait être utilisée seule.
Lorsque vous appelez $this->db->get() , qui fait partie de l’enregistrement actif, vous obtenez l’erreur “Aucune table trouvée” car vous ne fournissez pas encore de nom de table à cette méthode.

Vous pouvez changer $this->db->query($sql) utilisant un enregistrement actif à la place:

  $this->db->select('judul.id_judul, judul.judul_buku, judul.isbn, judul.penulis, judul.penerbit, judul.klasifikasi, judul.cover, judul.letak') ->select("IFNULL((SELECT COUNT(buku.id_buku) FROM buku WHERE buku.id_judul = judul.id_judul GROUP BY buku.id_judul),0) AS jumlah_total", false) ->select("IFNULL((SELECT COUNT(buku.id_buku) FROM buku WHERE buku.id_judul = judul.id_judul AND buku.is_ada = 'y' GROUP BY buku.id_judul),0) AS jumlah_ada", false) ->select("IFNULL((SELECT COUNT(buku.id_buku) FROM buku WHERE buku.id_judul = judul.id_judul AND AND buku.is_ada = 'n' GROUP BY buku.id_judul),0) AS jumlah_dipinjam", false) ->from('judul') ->group_by('judul.id_judul') ->order_by('judul.id_judul', 'DESC');