2011-09-10 1 views
4
$q = $this->createQuery('q') 
->where('q.group_id=?', $group_id) 
->andWhere('q.content=?', $content) 
    ->execute(); 

(例えば日本語/中国語)これは、次のメッセージが発生します

SQLSTATE[HY000]: General error: 1267 Illegal mix of collations 
(latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=' 

誰も前に同様の問題が発生しましたか?

答えて

1

あなたが見ていることができコレート機能の詳細については句は、列の照合順序にインバウンド・データを変換する必要があります(latin1_swedish_ci)

$q = $this->createQuery('q') 
->where('q.group_id=?', $group_id) 
->andWhere('q.content = _latin1 ? COLLATE latin1_swedish_ci', $content) 
    ->execute(); 

でのMySQLとCOLLATE関数を使用することができますhttp://dev.mysql.com/doc/refman/5.6/en/charset-collate.htmlに詳細がありますが、これは4.1のmysqlにあります。

詳細については、テーブル構造(http://dev.mysql.com/doc/refman/5.6/en/charset-column.htmlを参照)の定義で列ごとの照合順序を設定することもできます。

これが役に立ちます。

関連する問題