I have a problem with a SQL request :
SELECT CLCLEUNIK, NOM, VILLE, CODEP
FROM CLIENT
WHERE NOM LIKE :nom COLLATE French_CI_AI
In my case, I use the collate because a user can search "rhone" and it will find "rhône". But my problem is that now when someone searches "Rhône", the request doesn't find any match in my database.
Edit : this is the creation of the base :
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[CLIENT](
[NOM] [varchar](50) NULL,
[ADRESSE] [text] NULL,
[CODEP] [varchar](5) NULL,
[VILLE] [varchar](40) NULL,
[TYPECLI] [int] NULL,
[TEL] [varchar](20) NULL,
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
This is the php code :
public function searchCli(Request $request){
require __DIR__.DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."Entity".DIRECTORY_SEPARATOR."sqlconnect.php";
$nom = $request->request->has("nom") ? $request->request->get("nom") : "";
$nom = str_replace(" ", "%", $nom);
$req ="SELECT CLCLEUNIK, NOM, VILLE, CODEP FROM CLIENT WHERE NOM LIKE :nom COLLATE French_100_CI_AI";
$prepare = $pdo->prepare($req);
$prepare->execute(
[
"nom" => "%{$nom}%"
]
);
$clientsrecherche = $prepare->fetchAll(PDO::FETCH_OBJ);
foreach($clientsrecherche as $key => $objet){
foreach($objet as $key2 => $obj){
$obj=utf8_encode($obj);
$response[$key][$key2] = $obj;
};
}
return new JsonResponse([ "response" => $response]);
}
It's all I can have to help