Case insensitive search using server-side processing?
Case insensitive search using server-side processing?

Hi,
I'm currently trying to implement case insensitive search on my Datatables project. I've got server-side processing set to true, and I'm using the example server side PHP script and the complex function on ssp.class.php. I'm not sure how to make it such that case insensitive search is set by default. I'm using a MySQL server, and have tried replacing the LIKE statements in the filter function such that it is "LIKE BINARY," but neither that nor "ILIKE" are working. Is there a way to do this? Can post code if needed, but it's pretty similar to the examples shown in the documentation
Answers
Have you tried LOWER()?
Kevin
Hi @kthorngren sorry for the extremely late response, I had switched over to a different project for a bit.
I've thought about using LOWER(), but I'm not sure exactly where to put it. I've pasted the relevant code below from ssp.class.php, and put comments where I think LOWER() should go, but it's presenting me with errors and debugging is rather vague when it comes to this.
@allan maybe you'd be able to help with this as well?
Changing
LIKE
toILIKE
in the two lines where it is used in that code should be enough with MySQL. Actually, many MySQL databases use a case-insensitive collation anyway (which can be seen to be the case here). What collation are you using?Allan
I've tried ILIKE but I get a syntax error. I'm using MySQL and I believe ILIKE is limited to PostgresSQL. I thought the default was to be case insensitive, but my search is being case sensitive and I'm not sure what else could be causing it besides this
I'm not 100% sure which collation I'm using, but if I try and specify the collation (for example,
COLLATE utf8_general_ci
, it returnsSyntax error or access violation: 1253 COLLATION 'utf8_general_ci' is not valid for CHARACTER SET 'latin1'
, so I'm assuming the collation being used for the search is latin1? Sorry, I'm not too experienced with MySQLI've figured it out now. I just added the latin1_swedish_ci collation instead and it seemed to do the trick. Should probably move away from latin1 and to utf8 in general though. Thanks for all of the help!
You can use one of these queries to get the collation:
https://stackoverflow.com/questions/3832056/mysql-check-collation-of-a-table
I'm not familiar with PHP but would guess to use the LOWER() function like this:
Kevin