note 106870 deleted from sqlite3.createfunction by danbrown

From: Date: Tue, 03 Jan 2012 22:12:45 +0000
Subject: note 106870 deleted from sqlite3.createfunction by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-185334@lists.php.net to get a copy of this message
Note Submitter: remort at mail dot ru ---- i need to make a case insensitive 'like' search in sqlite (sqlite isn't able to perforn ci search on utf8 strings, for example in russian text). i found a hack for sqlite pdo driver here: http://blog.amartynov.ru/archives/php-sqlite-case-insensitive-like-utf8/ i tried to adopt it for sqlite3 syntax and made following: function ci_search($mask, $value){ echo $value; $mask = str_replace( array("%", "_"), array(".*?", "."), preg_quote($mask, "/") ); $mask = "/^$mask$/ui"; echo "PM = ",preg_match($mask, $value); echo "<br />"; return preg_match($mask, $value); } $db->createFunction('like', 'ci_search', 2); $query_firmname = $db->query('SELECT id FROM firms WHERE name like "%'.$firmname.'%"'); but the search cycle breaks whenever function returns '1'. it should continue searching through all the table firms but it stop at first successfull match. we can see that it goes through all the table if we comment "return..." string in function. it can find and print several "PM=1" messages, but now all the mechanism of popullating of $query_firmname variable is broken. i need to fix all the mechanism of popullating the array in the way it popullates onli when PM=1 (math was successful). please give me a sign if you know how to fix it. PS : anyway , case insensitive searching is already working ))

« previous php.notes (#185334) next »