0
How to query the database that ignores accents and other special characters?
I have the products table that has the name field with the following values:
"shoes", "Tennis", "Karaoke and Video", etc...
In the BD
the names of the products are accentuated and separated by space.
My URL: http://meusite.com.br/produtos/calcados
The products page receives the value "calcado" and I check if there are products with this name.
The problem is that, by the fact that in the bank the name of the product is engraved with accents and spaces, when sending "pressed" I do not find anything, because I have only recorded "footwear".
I’d also like him to consider compound words, like:
Karaoke and Video, Karaoke, Video...
SQL query
$con = $pdo->query("SELECT * FROM ws_cat_sub WHERE sub_categoria = 'calcados' ");
$return_id = $con->fetch(PDO::FETCH_OBJ);
What is the database manager?
– José Diz
i use Mysql.
– diogo Dsa
Evaluate the use of COLLATE in the WHERE clause to resolve the accentuation issue // For searching in compound words, evaluate the use of the LIKE operator. In this case, degradation in performance is likely to occur.
– José Diz
I think the best way would be to take all categories in array and pass str_replace then do the query ai yes clear spaces
– diogo Dsa