Replies: 1 comment 2 replies
-
I think this should be the last resort for a search like this, generally using functions in where is a bad idea in SQL since they cannot be indexed. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The problem
I often find myself chaining multiple fields to make a search query.
There are scenarios in which it is not necessary to rely on a more robust search system, such as Scout; instead it is sufficient to concatenate multiple fields and see if there is a match with a search key.
Eg:
The problem with using such a function is that it is tied to the underlying database engine.
I often use Sqlite locally, the same thing for testing, while in production I use Mysql. In Sqlite doesn't exists CONCAT_WS, so there isn't a "quick" way to achieve that.
The solution
My suggestion is to introduce function like this in Eloquent:
If you think it can be interesting I can propose a PR.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions