I have a small problem in my search field when the user searches for a word with an apostrophe " ’ ": which is common in French, since I use h(), when I redisplay the user’s query on the search page, it displays in raw ' and it searches the database with ' rather than ’
Posts.name LIKE ‘%army%’
OR Posts.description LIKE ‘%the army%’
and find nothing.
But the user is looking for: " armée " then the request is
Posts.name LIKE ‘%army%’
OR Posts.description LIKE ‘%army%’
And I have several results.
I suppose one solution is to remove all the little words with apostrophes " ’ " to send a simpler request but I would still like to find something simpler?
In my view, I displayed in the value of the form like this:
Sorry, still confused. If their search term is “armée”, how does that get translated into “army” in your query? And what if they search for “armee” with no accent?
This document? The references to bind in there all appear to be very specifically about scenarios where you’re writing “raw SQL snippets” and the like. What you’ve got here are standard where clauses with keys and values, and to my understanding those values are all going to be properly escaped and quoted by the ORM. If you are using ["Posts.name LIKE '%$v%'"], that’s a different story, but by separating the value out, the ORM has got your back.