Req #66637 [Wfx]: Please don't remove sql_regcase

From: Date: Tue, 04 Feb 2014 09:12:46 +0000
Subject: Req #66637 [Wfx]: Please don't remove sql_regcase
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184152@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66637&edit=1 ID: 66637 Updated by: requinix@php.net Reported by: marco at thenetworksolution dot it Summary: Please don't remove sql_regcase Status: Wont fix Type: Feature/Change Request Package: *Regular Expressions PHP Version: 5.4.24 Block user comment: N Private report: N New Comment: sql_regcase() has a very limited usage as far as I can see: matching single-byte characters when you need a REGEXP in MySQL. Because (1) it won't work correctly with multibyte characters, especially with more than one, (2) LIKE handles the general don't-need-full-regular-expressions use case, and (3) like I said before the PCRE functions are better for use in just PHP. If you really need the functionality then there is a straightforward userland solution: the one started by @irker on the manual page. Could use some touching up though, like using "(up|low)" instead of the flawed "[uplow]". (Searching around for "mb_sql_regcase" seems to turn up a number of results.) Previous Comments: ------------------------------------------------------------------------ [2014-02-04 07:23:03] marco at thenetworksolution dot it Hi. There is just one use case in which nor PCRE nor charset and collation are useful. This case is solvable with sql_regcase. Please consider this use case: "perform a case insensitive and accent insensitive word search (must match only entire words)" - utf8_general_ci allows you to make an equality (WHERE field = value) case and accent insensitive search but it doesn't allow you to specify an entire word match (word boundaries markers not recognized) - LIKE allows you case and accent insensitive search but you have to manually specify all combinations of possible word boundaries charactes (word boundaries markers not recognized) - word boundaries [[:<:]] and [[:>:]] are supported in REGEXP, who is a single byte functions so don't perform accent insensitive search. The solution is to use REGEXP with word boundaries and the word modified in the way sql_regcase does. Used on http://www.genovaperte.it ------------------------------------------------------------------------ [2014-02-03 20:17:48] requinix@php.net It has been deprecated because there are better alternatives: * In PHP: using the PCRE functions and the /i flag for case-insensitivity. * In SQL: depends on the DBMS but many problems can be solved by using the right charset and collation. In MySQL you'd use, for example, utf8_general_ci on the column. [1] [1] http://dev.mysql.com/doc/refman/5.6/en/charset-general.html ------------------------------------------------------------------------ [2014-02-03 20:05:51] marco at thenetworksolution dot it Description: ------------ Just noticed that I've just reimplemented in my project the sql_regcase. Please don't remove, it is useful in implementing accent insensitive searches on top of MySQL. --- From manual page: http://www.php.net/function.sql-regcase --- ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=66637&edit=1

« previous php.bugs (#184152) next »