This repository was archived by the owner on Jan 9, 2024. It is now read-only.
  
  
  
  
    
    
    
      
    
  
  
    
File tree Expand file tree Collapse file tree 6 files changed +12
-19
lines changed Expand file tree Collapse file tree 6 files changed +12
-19
lines changed Original file line number Diff line number Diff line change @@ -126,13 +126,13 @@ would produce the following query in `NATURAL_LANGUAGE` mode:
126126
127127
128128``` sql 
129- select  *  from  ` posts`   where  MATCH(content,meta) AGAINST(:_search  IN  NATURAL LANGUAGE MODE)
129+ select  *  from  ` posts`   where  MATCH(content,meta) AGAINST(?  IN  NATURAL LANGUAGE MODE)
130130``` 
131131
132132and the following query in ` BOOLEAN `  mode:
133133
134134``` sql 
135- select  *  from  ` posts`   where  MATCH(content,meta) AGAINST(:_search  IN  BOOLEAN  MODE)
135+ select  *  from  ` posts`   where  MATCH(content,meta) AGAINST(?  IN  BOOLEAN  MODE)
136136``` 
137137
138138Operators for ` BOOLEAN `  mode should be passed as part of the search string.
@@ -143,7 +143,7 @@ For more information see the
143143
144144### LIKE and LIKE_EXPANDED Modes  
145145
146- ` LIKE `  and ` LIKE_EXPANDED `  modes will run ` WHERE LIKE %:_search % `  queries that will include all of the Model's fields 
146+ ` LIKE `  and ` LIKE_EXPANDED `  modes will run ` WHERE LIKE %? % `  queries that will include all of the Model's fields 
147147returned from ` toSearchableArray() ` . ` LIKE_EXPANDED `  mode will query each field using each individual word in the search string.
148148
149149For example running a search on a ` Customer `  model with the following database structure:
Original file line number Diff line number Diff line change @@ -15,14 +15,14 @@ public function buildWhereRawString(Builder $builder)
1515
1616        $ indexFields  = implode (', ' ,  $ this  ->modelService ->setModel ($ builder ->model )->getFullTextIndexFields ());
1717
18-         $ queryString  .= "MATCH( $ indexFields) AGAINST(:_search  IN BOOLEAN MODE) " ;
18+         $ queryString  .= "MATCH( $ indexFields) AGAINST(?  IN BOOLEAN MODE) " ;
1919
2020        return  $ queryString ;
2121    }
2222
2323    public  function  buildParams (Builder   $ builder )
2424    {
25-         $ this  ->whereParams [' _search '  ] = $ builder ->query ;
25+         $ this  ->whereParams [] = $ builder ->query ;
2626
2727        return  $ this  ->whereParams ;
2828    }
Original file line number Diff line number Diff line change @@ -19,10 +19,8 @@ public function buildWhereRawString(Builder $builder)
1919
2020        $ queryString  .= '( ' ;
2121
22-         $ itr  = 0 ;
2322        foreach  ($ this  ->fields  as  $ field ) {
24-             $ queryString  .= "` $ field` LIKE :_search $ itr OR  " ;
25-             ++$ itr ;
23+             $ queryString  .= "` $ field` LIKE ? OR  " ;
2624        }
2725
2826        $ queryString  = trim ($ queryString , 'OR  ' );
@@ -34,7 +32,7 @@ public function buildWhereRawString(Builder $builder)
3432    public  function  buildParams (Builder   $ builder )
3533    {
3634        for  ($ itr  = 0 ; $ itr  < count ($ this  ->fields ); ++$ itr ) {
37-             $ this  ->whereParams [" _search $ itr "  ] = '% ' .$ builder ->query .'% ' ;
35+             $ this  ->whereParams [] = '% ' .$ builder ->query .'% ' ;
3836        }
3937
4038        return  $ this  ->whereParams ;
Original file line number Diff line number Diff line change @@ -21,12 +21,9 @@ public function buildWhereRawString(Builder $builder)
2121
2222        $ queryString  .= '( ' ;
2323
24-         $ itr  = 0 ;
25- 
2624        foreach  ($ this  ->fields  as  $ field ) {
2725            foreach  ($ words  as  $ word ) {
28-                 $ queryString  .= "` $ field` LIKE :_search $ itr OR  " ;
29-                 ++$ itr ;
26+                 $ queryString  .= "` $ field` LIKE ? OR  " ;
3027            }
3128        }
3229
@@ -40,11 +37,9 @@ public function buildParams(Builder $builder)
4037    {
4138        $ words  = explode ('  ' , $ builder ->query );
4239
43-         $ itr  = 0 ;
4440        for  ($ i  = 0 ; $ i  < count ($ this  ->fields ); ++$ i ) {
4541            foreach  ($ words  as  $ word ) {
46-                 $ this  ->whereParams ["_search $ itr " ] = '% ' .$ word .'% ' ;
47-                 ++$ itr ;
42+                 $ this  ->whereParams [] = '% ' .$ word .'% ' ;
4843            }
4944        }
5045
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ protected function buildWheres(Builder $builder)
3737
3838            $ this  ->whereParams [$ field ] = $ value ;
3939
40-             $ queryString  .= "$ field  $ operator :  $ field  AND  " ;
40+             $ queryString  .= "$ field  $ operator ?  AND  " ;
4141        }
4242
4343        return  $ queryString ;
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ public function buildWhereRawString(Builder $builder)
1414
1515        $ indexFields  = implode (', ' ,  $ this  ->modelService ->setModel ($ builder ->model )->getFullTextIndexFields ());
1616
17-         $ queryString  .= "MATCH( $ indexFields) AGAINST(:_search  IN NATURAL LANGUAGE MODE " ;
17+         $ queryString  .= "MATCH( $ indexFields) AGAINST(?  IN NATURAL LANGUAGE MODE " ;
1818
1919        if  (config ('scout.mysql.query_expansion ' )) {
2020            $ queryString  .= ' WITH QUERY EXPANSION ' ;
@@ -27,7 +27,7 @@ public function buildWhereRawString(Builder $builder)
2727
2828    public  function  buildParams (Builder   $ builder )
2929    {
30-         $ this  ->whereParams [' _search '  ] = $ builder ->query ;
30+         $ this  ->whereParams [] = $ builder ->query ;
3131
3232        return  $ this  ->whereParams ;
3333    }
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments