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

Fix where() not working #126

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix where() not working #126

wants to merge 1 commit into from

Conversation

diezg
Copy link

@diezg diezg commented Dec 22, 2021

Hi, I was trying to use ->where() after ->search() with no success. The problem was the order of the parameters in the query.
I realized that commenting a line in src/Engines/MySQLEngine.php fixes it.

Example with query Inventory::search('papa')->where('category_id', 97)->get():
Before change:

"query" => "select *, MATCH(name,tags) AGAINST(? IN NATURAL LANGUAGE MODE) as relevance from `inventories` where category_id = ? AND MATCH(name,tags) AGAINST(? IN NATURAL LANGUAGE MODE) and `inventories`.`deleted_at` is null"
 "bindings" => array:3 [
   0 => "papa"
   1 => "papa"
   2 => 97
 ]

After change, bindings are in correct order:

    "query" => "select *, MATCH(name,tags) AGAINST(? IN NATURAL LANGUAGE MODE) as relevance from `inventories` where category_id = ? AND MATCH(name,tags) AGAINST(? IN NATURAL LANGUAGE MODE) and `inventories`.`deleted_at` is null"
    "bindings" => array:3 [
      0 => "papa"
      1 => 97
      2 => "papa"
    ]

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant