sql >> Database >  >> RDS >> Mysql

Gegevenstabellen die tabellen samenvoegen zoeken en bestellen zit vast met codeigniter

op basis van uw modellen, kunt u deze aanpassen zoals hieronder

private function _get_datatables_query($term=''){ //term is value of $_REQUEST['search']['value']
    $column = array('k.id_kota','k.nm_kota', 'p.nm_propinsi');
    $this->db->select('k.id_kota, k.nm_kota, p.nm_propinsi');
    $this->db->from('kota as k');
    $this->db->join('propinsi as p', 'p.id_propinsi = k.id_propinsi','left');
    $this->db->like('k.id_kota', $term);
    $this->db->or_like('k.nm_kota', $term);
    $this->db->or_like('p.nm_propinsi', $term);
    if(isset($_REQUEST['order'])) // here order processing
    {
       $this->db->order_by($column[$_REQUEST['order']['0']['column']], $_REQUEST['order']['0']['dir']);
    } 
    else if(isset($this->order))
    {
       $order = $this->order;
       $this->db->order_by(key($order), $order[key($order)]);
    }
}

function get_datatables(){
  $term = $_REQUEST['search']['value'];   
  $this->_get_datatables_query($term);
  if($_REQUEST['length'] != -1)
  $this->db->limit($_REQUEST['length'], $_REQUEST['start']);
  $query = $this->db->get();
  return $query->result(); 
}

function count_filtered(){
  $term = $_REQUEST['search']['value']; 
  $this->_get_datatables_query($term);
  $query = $this->db->get();
  return $query->num_rows();  
}

public function count_all(){
  $this->db->from($this->table);
  return $this->db->count_all_results();  
}


  1. Hoe een koppelingstabel correct te indexeren voor veel-op-veel-verbindingen in MySQL?

  2. MySQL:SELECTEER UNIEKE WAARDE

  3. Hoe de lekkage van de databaseverbinding in de Java EE-toepassing te controleren?

  4. CRUD-bewerking met ASP.NET Core MVC, Entity Framework Core en SQL Server