1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 05:50:42 +02:00

[ticket/12671] Possibility to use NOT LIKE expression

PHPBB3-12671
This commit is contained in:
Geolim4
2014-08-08 18:32:17 +02:00
parent 6b60153ab4
commit 01943adbf7
3 changed files with 43 additions and 14 deletions

View File

@@ -377,7 +377,7 @@ abstract class driver implements driver_interface
$expression = utf8_str_replace(array('_', '%'), array("\_", "\%"), $expression);
$expression = utf8_str_replace(array(chr(0) . "\_", chr(0) . "\%"), array('_', '%'), $expression);
return $this->_sql_like_expression('NOT LIKE \'' . $this->sql_escape($expression) . '\'');
return $this->_sql_not_like_expression('NOT LIKE \'' . $this->sql_escape($expression) . '\'');
}
/**

View File

@@ -274,6 +274,23 @@ class sqlite3 extends \phpbb\db\driver\driver
return 'GLOB \'' . $this->sql_escape($expression) . '\'';
}
/**
* {@inheritDoc}
*
* For SQLite an underscore is a not-known character...
*/
public function sql_not_like_expression($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($expression) . '\'';
}
/**
* return sql error array
*