Characters “ي” and “ی” and the difference in persian - Mysql

前端 未结 8 1182
忘掉有多难
忘掉有多难 2020-12-23 19:56

I\'m working on a UTF-8 Persian website with integrated mysql database. All the content in the website are imported through an admin panel and it\'s all persian.

As

8条回答
  •  梦毁少年i
    2020-12-23 20:20

    I was struggling with the similar situation 5-6 years ago, when Lucene was not an option for MySQL and there were no Sphinx (Never tried Sphinx result on this), but what I did was I found pretty much most of the possible alternations and put them in an array in PHP. So if the input keyword contained any of those characters, I generated all the possible alternates of that.

    So for the input of 'بازی' I would have generated {'بازي' , 'بازی' } and then I would query the MySQL for both, like the simplest query below :

    SELECT title,Describtion FROM Games WHERE Description LIKE '%بازي%' OR Description LIKE '%بازی%' 
    

    The primary list of alternatives is not very long though.

提交回复
热议问题