Server Side Processing - multiple word search

Server Side Processing - multiple word search

rclippirclippi Posts: 9Questions: 1Answers: 0

The code in this post: https://datatables.net/forums/discussion/3343/server-side-processing-and-regex-search-filter is not showing properly. Can anyone have the full code?

Answers

  • rclippirclippi Posts: 9Questions: 1Answers: 0

    *Does anyone have the full code?

  • rclippirclippi Posts: 9Questions: 1Answers: 0

    I think that code wouldn´t work in the 1.10 version right? I think the ssp.class is very different.

  • rclippirclippi Posts: 9Questions: 1Answers: 0
    edited January 2017

    This code works like using "OR". It returns any word in the search field. How to return the registers only if all the words were found:

     if ( isset($request['search']) && $request['search']['value'] != '' ) {
                        $str = $request['search']['value'];
    
                        for ( $i=0, $ien=count($request['columns']) ; $i<$ien ; $i++ ) {
                                $requestColumn = $request['columns'][$i];
                                $columnIdx = array_search( $requestColumn['data'], $dtColumns );
                                $column = $columns[ $columnIdx ];
    
                                if ( $requestColumn['searchable'] == 'true' )
                                $strArray = explode(' ',$str);
                                foreach ($strArray as $str)
                                {
                                        $binding = self::bind( $bindings, '%'.$str.'%', PDO::PARAM_STR );
                                        $globalSearch[] = "`".$column['db']."` LIKE ".$binding;
                                }
                        }
                }
    
  • rclippirclippi Posts: 9Questions: 1Answers: 0

    I tried using foreach to add "AND" at each word but that didn't work either.

  • rclippirclippi Posts: 9Questions: 1Answers: 0

    How to change the code to add "AND" instead of "OR"?

    I understand that the $globalSearch[] = "".$column['db']." LIKE ".$binding; is using "OR" to unite the terms, how to change to "AND"?

  • rclippirclippi Posts: 9Questions: 1Answers: 0

    Allan said in other post:

    You'll need to build up the search pattern (probably in PHP), then concatenate the searchable columns together and perform the search on the resulting string.

    And that's what I am trying to do. Can anyone help?

This discussion has been closed.