Can't search contain underscore (string)

Can't search contain underscore (string)

dheirodheiro Posts: 2Questions: 0Answers: 0
edited April 2017 in Free community support

Hi, i use server side using ajax, when i search with underscore keyword (_) it result no record fount.
but i'm run manual query is work fine in mysql with LIKE

and use IgnitedDatatables for codeigniter

Best regard,


  • allanallan Posts: 48,883Questions: 1Answers: 7,122 Site admin

    If you are using server-side processing, this is a server-side issue, since the filtering is done there. Specifically in this case an underscore in an SQL wildcard means "any character". The server-side script (IgnitedDatatables in this case) would need to escape the underscore.


  • dheirodheiro Posts: 2Questions: 0Answers: 0

    Thanks for the answer, im solving this issue by remove escape_like_str in codeigniter library, but result not accurate.

  • tangerinetangerine Posts: 2,215Questions: 17Answers: 244

    Are you asking the author of IgnitedDatatables about this?

  • bsulzbsulz Posts: 1Questions: 0Answers: 0

    2 years later, but this may be helpful to anyone with the same issue. Using Ignited Tables v 2.0.1 <beta>, you will need to edit the LIKE lines in the get_filtering() method from :

    $sWhere .= $this->select[$mColArray[$i]['data']] . " LIKE '%" . $sSearch . "%' OR ";


    $sWhere .= $this->select[$mColArray[$i]['data']] . " LIKE '%" . $sSearch . "%' ESCAPE '!' OR ";
 explains the reason:

    "The escape_like_str() method uses ‘!’ (exclamation mark) to escape special characters for LIKE conditions. Because this method escapes partial strings that you would wrap in quotes yourself, it cannot automatically add the ESCAPE '!' condition for you, and so you’ll have to manually do that."

Sign In or Register to comment.