我的网站有多种语言,因此文章的标题取决于当地.但是有一个问题:我如何搜索另一种语言的文章?
现在,唯一的方法是用英文键入标题,以便cakePHP用法语检索名称,例如.我不能用法语搜索它.
例如:当我搜索"你好"时,我找到了一篇名为"Bonjour"的文章但是当我搜索"Bonjour"时,我找不到任何文章.
那么如何使用其他语言进行搜索?似乎Cakephp首先使用默认语言进行搜索,然后进行转换.
在我的控制器中:
$this->Ingredients->locale('fr_CA');
$data = $this->Ingredients->find('all')
->select([
'Ingredients.id',
'Ingredients.name'
])
->where(["Ingredients.name LIKE '%".$this->request->query['k']."%'"])
->order('Ingredients.recipe_count');
Run Code Online (Sandbox Code Playgroud)