Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
Fix for fulltext w/where() not working
Browse files Browse the repository at this point in the history
When using fulltext search + where() clause(s) in place even when I knew the combination should bring entries none was retrieved.

I found that the $params array get populated in the wrong order.

Eg;

select *, MATCH(name,email,data) AGAINST(? IN NATURAL LANGUAGE MODE) AS relevance from `users` where guid = ? AND MATCH(name,email,data) AGAINST(? IN BOOLEAN MODE)

array:2 [▼
  "guid" => "9260a604-22b6-4075-891e-a82d52ba69fe"
  0 => "text2search4"
]

after ksort($params,SORT_NATURAL); the $params lists gets;

array:2 [▼
  0 => "text2search4"
  "guid" => "9260a604-22b6-4075-891e-a82d52ba69fe"
]
  • Loading branch information
gmartinez authored and msonowal committed Dec 8, 2021
1 parent 83e0662 commit e8dadf9
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/Engines/MySQLEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public function search(Builder $builder)

$whereRawString = $mode->buildWhereRawString($builder);
$params = $mode->buildParams($builder);
ksort($params,SORT_NATURAL);

$model = $builder->model;
$query = $model::whereRaw($whereRawString, $params);
Expand Down

0 comments on commit e8dadf9

Please sign in to comment.