From 5aa220bcd21c6e3decd8f2b9833dc90a8ee6a274 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 24 Jun 2007 12:49:13 +0000 Subject: tweak the sql_like_expression feature a little bit to allow correct escaping git-svn-id: file:///svn/phpbb/trunk@7789 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/db/sqlite.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/db/sqlite.php') diff --git a/phpBB/includes/db/sqlite.php b/phpBB/includes/db/sqlite.php index 88a0d612b4..3248b439c6 100644 --- a/phpBB/includes/db/sqlite.php +++ b/phpBB/includes/db/sqlite.php @@ -247,12 +247,14 @@ class dbal_sqlite extends dbal */ function sql_like_expression($expression) { - if (strpos($expression, '_') === false) - { - return "LIKE '" . $this->sql_escape($expression) . "'"; - } + // Unlike LIKE, GLOB is case sensitive (unfortunatly). SQLite users need to live with it! + // We only catch * and ? here, not the character map possible on file globbing. + $expression = str_replace(array(chr(0) . '_', chr(0) . '%'), array(chr(0) . '?', chr(0) . '*'), $expression); + + $expression = str_replace(array('?', '*'), array("\?", "\*"), $expression); + $expression = str_replace(array(chr(0) . "\?", chr(0) . "\*"), array('?', '*'), $expression); - return "GLOB '" . $this->sql_escape(str_replace('%', '*', $expression)) . "'"; + return 'GLOB \'' . $this->sql_escape($expression) . '\''; } /** -- cgit v1.2.1