操作 'like' 的归类与 PDO bindValue() 的非法混合

Illegal mix of collations for operation 'like' with PDO bindValue()

我将代码从 mysql_query 更改为 pdo prepare()、bindValue() 和 execute()

但是使用新代码,当我将希伯来语值绑定到 :t0 以进行查询时

select * from product where ( prd_name_HEB like :t0 or prd_code like :t0 ) 

我明白了

General error: 1267 Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (hebrew_general_ci,COERCIBLE) for operation 'like'

我现在无法将整个数据库更改为 utf8_unicode_ci。

我知道我可以在我的查询中使用 COLLATE 来设置排序规则,但我不知道在哪里添加它。

  1. 请告诉我正确的语法是什么,"like" 和 "COLLATE" 用于以下查询:

    select * 来自产品 where ( prd_name_HEB like :t0 or prd_code like :t0 )

  2. 有没有办法向 PDO bindValue() 添加排序规则?

谢谢。

已解决:

if searchString.containsHebrewCharacters()
  select * from product where ( prd_name_HEB like :t0 )
else
  select * from product where ( prd_name_HEB like :t0 or prd_code like :t0 )