This repository was archived by the owner on Jan 9, 2024. It is now read-only.
File tree 6 files changed +12
-19
lines changed
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:
126
126
127
127
128
128
``` 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)
130
130
```
131
131
132
132
and the following query in ` BOOLEAN ` mode:
133
133
134
134
``` 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)
136
136
```
137
137
138
138
Operators for ` BOOLEAN ` mode should be passed as part of the search string.
@@ -143,7 +143,7 @@ For more information see the
143
143
144
144
### LIKE and LIKE_EXPANDED Modes
145
145
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
147
147
returned from ` toSearchableArray() ` . ` LIKE_EXPANDED ` mode will query each field using each individual word in the search string.
148
148
149
149
For 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)
15
15
16
16
$ indexFields = implode (', ' , $ this ->modelService ->setModel ($ builder ->model )->getFullTextIndexFields ());
17
17
18
- $ queryString .= "MATCH( $ indexFields) AGAINST(:_search IN BOOLEAN MODE) " ;
18
+ $ queryString .= "MATCH( $ indexFields) AGAINST(? IN BOOLEAN MODE) " ;
19
19
20
20
return $ queryString ;
21
21
}
22
22
23
23
public function buildParams (Builder $ builder )
24
24
{
25
- $ this ->whereParams [' _search ' ] = $ builder ->query ;
25
+ $ this ->whereParams [] = $ builder ->query ;
26
26
27
27
return $ this ->whereParams ;
28
28
}
Original file line number Diff line number Diff line change @@ -19,10 +19,8 @@ public function buildWhereRawString(Builder $builder)
19
19
20
20
$ queryString .= '( ' ;
21
21
22
- $ itr = 0 ;
23
22
foreach ($ this ->fields as $ field ) {
24
- $ queryString .= "` $ field` LIKE :_search $ itr OR " ;
25
- ++$ itr ;
23
+ $ queryString .= "` $ field` LIKE ? OR " ;
26
24
}
27
25
28
26
$ queryString = trim ($ queryString , 'OR ' );
@@ -34,7 +32,7 @@ public function buildWhereRawString(Builder $builder)
34
32
public function buildParams (Builder $ builder )
35
33
{
36
34
for ($ itr = 0 ; $ itr < count ($ this ->fields ); ++$ itr ) {
37
- $ this ->whereParams [" _search $ itr " ] = '% ' .$ builder ->query .'% ' ;
35
+ $ this ->whereParams [] = '% ' .$ builder ->query .'% ' ;
38
36
}
39
37
40
38
return $ this ->whereParams ;
Original file line number Diff line number Diff line change @@ -21,12 +21,9 @@ public function buildWhereRawString(Builder $builder)
21
21
22
22
$ queryString .= '( ' ;
23
23
24
- $ itr = 0 ;
25
-
26
24
foreach ($ this ->fields as $ field ) {
27
25
foreach ($ words as $ word ) {
28
- $ queryString .= "` $ field` LIKE :_search $ itr OR " ;
29
- ++$ itr ;
26
+ $ queryString .= "` $ field` LIKE ? OR " ;
30
27
}
31
28
}
32
29
@@ -40,11 +37,9 @@ public function buildParams(Builder $builder)
40
37
{
41
38
$ words = explode (' ' , $ builder ->query );
42
39
43
- $ itr = 0 ;
44
40
for ($ i = 0 ; $ i < count ($ this ->fields ); ++$ i ) {
45
41
foreach ($ words as $ word ) {
46
- $ this ->whereParams ["_search $ itr " ] = '% ' .$ word .'% ' ;
47
- ++$ itr ;
42
+ $ this ->whereParams [] = '% ' .$ word .'% ' ;
48
43
}
49
44
}
50
45
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ protected function buildWheres(Builder $builder)
37
37
38
38
$ this ->whereParams [$ field ] = $ value ;
39
39
40
- $ queryString .= "$ field $ operator : $ field AND " ;
40
+ $ queryString .= "$ field $ operator ? AND " ;
41
41
}
42
42
43
43
return $ queryString ;
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ public function buildWhereRawString(Builder $builder)
14
14
15
15
$ indexFields = implode (', ' , $ this ->modelService ->setModel ($ builder ->model )->getFullTextIndexFields ());
16
16
17
- $ queryString .= "MATCH( $ indexFields) AGAINST(:_search IN NATURAL LANGUAGE MODE " ;
17
+ $ queryString .= "MATCH( $ indexFields) AGAINST(? IN NATURAL LANGUAGE MODE " ;
18
18
19
19
if (config ('scout.mysql.query_expansion ' )) {
20
20
$ queryString .= ' WITH QUERY EXPANSION ' ;
@@ -27,7 +27,7 @@ public function buildWhereRawString(Builder $builder)
27
27
28
28
public function buildParams (Builder $ builder )
29
29
{
30
- $ this ->whereParams [' _search ' ] = $ builder ->query ;
30
+ $ this ->whereParams [] = $ builder ->query ;
31
31
32
32
return $ this ->whereParams ;
33
33
}
You can’t perform that action at this time.
0 commit comments