Skip to content

Query\Builder::whereRaw() doesn't accept parameters #13679

@guoyunhe

Description

@guoyunhe

I have the following code and expect to pass $search into the raw query:

$tags = Tag::whereHas('translations', function ($query) use ($search) {
    $query->whereRaw("MATCH(`name`) AGAINST(? IN BOOLEAN MODE)", [$search]);
    echo $query->toSql();
})->get();

SQL dump:

select * from `tag_translation` where `tag_translation`.`tag_id` = `tag`.`id` and MATCH(`name`) AGAINST(? IN BOOLEAN MODE)

The ? is not replaced by $search.

Cannot find useful document about the whereRaw() function. Is here any good way to excute a raw SQL for fulltext index?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions