diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php index db469ed969..cf54d455f7 100644 --- a/phpBB/includes/db/dbal.php +++ b/phpBB/includes/db/dbal.php @@ -521,6 +521,18 @@ class dbal return $expression; } + /** + * Run LOWER() on DB column of type text (i.e. neither varchar nor char). + * + * @param string $column_name The column name to use + * + * @return string A SQL statement like "LOWER($column_name)" + */ + function sql_lower_text($column_name) + { + return "LOWER($column_name)"; + } + /** * Run more than one insert statement. * diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php index fd11dbad3c..abeabc389f 100644 --- a/phpBB/includes/db/mssql.php +++ b/phpBB/includes/db/mssql.php @@ -324,6 +324,14 @@ class dbal_mssql extends dbal return str_replace(array("'", "\0"), array("''", ''), $msg); } + /** + * {@inheritDoc} + */ + function sql_lower_text($column_name) + { + return "LOWER(SUBSTRING($column_name, 1, DATALENGTH($column_name)))"; + } + /** * Build LIKE expression * @access private diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php index 7ead00cece..6e24f4e9e8 100644 --- a/phpBB/includes/db/mssql_odbc.php +++ b/phpBB/includes/db/mssql_odbc.php @@ -309,6 +309,14 @@ class dbal_mssql_odbc extends dbal return str_replace(array("'", "\0"), array("''", ''), $msg); } + /** + * {@inheritDoc} + */ + function sql_lower_text($column_name) + { + return "LOWER(SUBSTRING($column_name, 1, DATALENGTH($column_name)))"; + } + /** * Build LIKE expression * @access private diff --git a/phpBB/includes/db/mssqlnative.php b/phpBB/includes/db/mssqlnative.php index 8aac032135..8a4503f111 100644 --- a/phpBB/includes/db/mssqlnative.php +++ b/phpBB/includes/db/mssqlnative.php @@ -491,6 +491,14 @@ class dbal_mssqlnative extends dbal return str_replace(array("'", "\0"), array("''", ''), $msg); } + /** + * {@inheritDoc} + */ + function sql_lower_text($column_name) + { + return "LOWER(SUBSTRING($column_name, 1, DATALENGTH($column_name)))"; + } + /** * Build LIKE expression * @access private diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 9798e514c1..5d19cd7adb 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2556,7 +2556,8 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id { $sql_keywords .= $db->sql_in_set('l.log_operation', $operations) . ' OR '; } - $sql_keywords .= 'LOWER(l.log_data) ' . implode(' OR LOWER(l.log_data) ', $keywords) . ')'; + $sql_lower = $db->sql_lower_text('l.log_data'); + $sql_keywords .= "$sql_lower " . implode(" OR $sql_lower ", $keywords) . ')'; } if ($log_count !== false)