0

i have a collection in mongodb

array( 'name'=>'Péter' )

when i query $this->mongo_db->like('name', 'Péter', 'i', true, true) so success but

query $this->mongo_db->like('name', 'Peter', 'i', true, true) no result

i used codeigniter alex bibie

Thanks in advance!

Allen Chak
  • 1,802
  • 1
  • 10
  • 21

2 Answers2

1

The standard solution to this problem is to store a second array with the normalized strings, as described in this answer.

Community
  • 1
  • 1
paulmelnikow
  • 16,895
  • 8
  • 63
  • 114
  • oh it's mean i must store as array('name'=>'Péter','name_no_utf8'=>'Peter') and my database will to distended when i have collections . Some other ideas .... – Hong Chung Cát Oct 17 '13 at 03:19
0

e and é are two totally different characters. Although you may want some sort of character folding for names, in most other scenarios you would freak out if "e" == "é".

MongoDB does't support collations or automatic converting of characters so this is not going to work. You'll have to normalize it yourself if you want such matching.

bjori
  • 2,064
  • 1
  • 15
  • 15
  • ok perhaps i'll storage more 1 array() accent names and no accent names in my db... this is also a solution but my db will to distended.... huh(mysql very easy for this occasion but mongodb nothing to do so i hate mongo but i still have to work with it) ... – Hong Chung Cát Oct 22 '13 at 08:56