Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart Search #139

Open
Nounours13 opened this issue Jul 18, 2019 · 1 comment
Open

Smart Search #139

Nounours13 opened this issue Jul 18, 2019 · 1 comment

Comments

@Nounours13
Copy link

Hi, I've a projet where i must use smart search on datatable (many word on many column).
If anybody have the same problem, i've change the code to this (line 327)

  if($sSearch != '')
    {

      $sSearch_explode = explode(" ",$sSearch);
      foreach ($sSearch_explode as $sSearch)
        {
          $sWhere .= '(';
          for($i = 0; $i < count($mColArray); $i++)
          {
            if ($mColArray[$i]['searchable'] == 'true' && !array_key_exists($mColArray[$i]['data'], $this->add_columns))
              {
                if($this->check_cType())
                  {
                    $sWhere .= $this->select[$mColArray[$i]['data']] . " LIKE '%" . $sSearch . "%' OR ";
                  }               
                else
                  {
                    $sWhere .= $this->select[$this->columns[$i]] . " LIKE '%" . $sSearch . "%' OR ";
                  }
                
              }
           
          }
          $sWhere = substr_replace($sWhere, '', -3);
          $sWhere .= ') AND ';
        }
     
      
    }  
    


  $sWhere = substr_replace($sWhere, '', -4);
@rorkyendo
Copy link

rorkyendo commented Aug 19, 2020

private function get_filtering()
{
  $mColArray = $this->ci->input->post('columns');
  $sWhere = '';
  $search = $this->ci->input->post('search');
  $sSearch = $this->ci->db->escape_like_str(trim($search['value']));
  $columns = array_values(array_diff($this->columns, $this->unset_columns));
  if($sSearch != '')
    for($i = 0; $i < count($mColArray); $i++)
      if ($mColArray[$i]['searchable'] == 'true' && !array_key_exists($mColArray[$i]['data'], $this->add_columns))
      if (!empty($mColArray[$i]['data'])) {
        if($this->check_cType())
            $sWhere .= $mColArray[$i]['data'] . " LIKE '%" . $sSearch . "%' OR ";
        else
          $sWhere .= $this->select[$this->columns[$i]] . " LIKE '%" . $sSearch . "%' OR ";
        }
  $sWhere = substr_replace($sWhere, '', -3);
  if($sWhere != '')
    $this->ci->db->where('(' . $sWhere . ')');
  // TODO : sRangeSeparator
  foreach($this->filter as $val)
    $this->ci->db->where($val[0], $val[1], $val[2]);
}

i try to change like this, but you can't use order by on query. just use order on javascript of datatables it will ordering from server side too.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants