Jump to content

Recommended Posts

Posted
Hello! 
 
My first post on the forum and I start with a question. 
I'm trying to modify the module datatable by Soma and I want to search  by $page->id. 
 
code:
 
if( $this->input->get->sSearch ) {
$q = $this->sanitizer->text($this->input->get->sSearch);
$selector .= "title|body%=$q,";
}

my code (doesn´t work):

if( $this->input->get->sSearch ) {
$q = $this->sanitizer->text($this->input->get->sSearch);
$selector .= "id|title|body%=$q,";
}
 
$thanks->ryan;
$thanks->soma;
 
And please excuse my bad English
Posted

@blad - welcome to the forums!

not totally sure here, but could possibly be an issue with trying to sanitize as text, since ID is (int).

have you tried it without the sanitizer, and also have you tried it with different operators like *= and ~=?'

  • Like 1
Posted

Id is integer and not fulltext. You can't mix them with % but maybe with * . But you may need to have some additional logic to check if search is an Id or text.

  • Like 1
Posted

Thanks @Macrura and thanks @Soma .

I will try. Can i add an autonumeric field or a copy of id as text? My client want to search a number.

Posted

Hi Blad,

You can do this with some additional logic:

if( $this->input->get->sSearch ) {
  $q = $this->sanitizer->text($this->input->get->sSearch);
  if (is_numeric($q)) {
    $selector .= "id=$q,";
  } else {
    $selector .= "title|body%=$q,";
  }
}
  • Like 3

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...