Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Illegal mix of collations for operation 'like' while searching #38

Closed
yahyaerturan opened this issue Sep 5, 2013 · 8 comments
Closed

Comments

@yahyaerturan
Copy link

I have successfully implemented Ignited-Datatables, works like a charm, thank you. However, while searching with database when typing "non-latin" characters like "İ,ş,ğ,.."

POST http://vproject.dev/module/user/ign_listing 500 (Internal Server Error)

Details are:

Illegal mix of collations for operation 'like' while searching

... (u.id_user LIKE '%Ä°%' OR u.first_name LIKE '%Ä°%' OR u.last_name LIKE '%Ä°%' OR ue.email LIKE '%Ä°%' OR u.last_login LIKE '%Ä°%' ) ...

'%Ä°%' part changes according to the non-latin character you typed.

Any idea for solving this?

@cryogenix
Copy link
Member

there is an optional second parameter for generate() to accept custom charsets. see here:
https://github.com/IgnitedDatatables/Ignited-Datatables/wiki/Function-Reference#this-datatables-generateoutput-charset

@yahyaerturan
Copy link
Author

Sure, default is utf-8 and I generate it utf-8. It is stored in db table as utf-8 all. That's why I am stacked and don't know how to fix it.

echo $this->datatables->generate('json','utf-8');

I think, the problem is how it posts. For example if I type 'ş', error must be query must be LIKE '%ş%', not 'LIKE '%Ä°%'.

@cryogenix
Copy link
Member

use ISO-8859-1

@yahyaerturan
Copy link
Author

cryogenix, it makes no different. Forcing to use something is not quite a solution indeed. when using dataTables without Ignited-Tables, it works. So problem is handling POST data.

@n1crack
Copy link
Member

n1crack commented Sep 5, 2013

Yahya Bey merhaba,
html encode olarak utf-8 kullandığını kontrol edebilir misiniz? Ajax ile bilgi göndermek istediğinde, html gönderdiğin değerleri utf-8 olarak yorumlamıyor olabilir. Karşılayan ajax sayfası da sonuçta farklı bir karakter görerek onu sorgulatıyordur.

Saygılarımla,
Regards.

@yahyaerturan
Copy link
Author

n1Crack, yanıt için teşekkürler..
Öncelikle tüm sayfalar UTF-8(without BOM) ve Unix style EOL.
.htaccess'te AddDefaultCharset UTF-8
index.php'de ini_set('default_charset','utf-8');
Ajax tarafında contentType form..., utf-8
Ajax'ın çağrıldığı sayfada meta charset utf-8
ancak $this->input->post('sSearch') değişik geliyor. utf8_decode yaptığımda da '?'ne dönüyor, sanırım özünde gelen data utf-8 ama saçımızı beyazlatıyor..

@yahyaerturan
Copy link
Author

Yusuf Bey, merhaba,
Post datasının utf-8 döndüğünü, sSearch datasını utf8 ile kodlanmış bir dosyaya yazdırarak teyit ettim.
Aynı şekilde sorgu kısmını da onayladım.

$this->writelog($this->ci->db->last_query());
if($output == 'json')
{ ...

Problem biraz daha mysql tarafında olmalı. Çünkü türkçe karakter ile arama yaptığınız zaman son çalışan sorgu yenilenmiyor. Yani bu yazının başlığına dönüp orada takılıyoruz.

get_filtering()

if($sWhere != '')
        $this->ci->db->where('(' . $sWhere . ' ) COLLATE utf8_bin ');
        // ya da         $this->ci->db->where('(' . $sWhere . ' COLLATE utf8_bin ) ');

da bir değişiklik yaratmadı. "Illegal mix of collations for operation 'like'" kısmında yatıyor çözüm.

Veritabanını da iki kez kontrol ettim, tüm tablolar ve text alanlarında utf8 collate var, tablo charset'leri de utf8.

Umarım yardımı olur.

@yahyaerturan
Copy link
Author

http://stackoverflow.com/questions/15535674/mysql-query-issue-illegal-mix-of-collations-for-operation-like?rq=1

Yukarıdaki sorunun id ve datetime alanları olduğuna dair yazı. Benim örneğime uyarlayarak test ettim, sonuç id alanları problem yaratmıyor, ancak DATETIME alanı eklendiği anda "illegal collation" uyarısı çıkıyor. Sanıyorum işin Ignited-Datatables ile bir ilgisi yok, dolayısıyla teşekkür ediyor ve konuyu kapatıyorum.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants