mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
new wrapper for LIKE expressions to streamline the fixes. We actually need to adjust them for different DBMS as well as SQLite2 not supporting escaping characters in LIKE statements (which is a reason why we think about dropping sqlite support completely).
git-svn-id: file:///svn/phpbb/trunk@7788 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -191,6 +191,21 @@ class dbal
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Correctly adjust LIKE expression for special characters
|
||||
* Some DBMS are handling them in a different way we need to take into account
|
||||
*/
|
||||
function sql_like_expression($expression)
|
||||
{
|
||||
// Standard for most DBMS
|
||||
if (strpos($expression, '_') === false)
|
||||
{
|
||||
return 'LIKE \'' . $this->sql_escape($expression) . '\'';
|
||||
}
|
||||
|
||||
return 'LIKE \'' . $this->sql_escape(str_replace('_', "\_", $expression)) . '\'';
|
||||
}
|
||||
|
||||
/**
|
||||
* SQL Transaction
|
||||
* @access private
|
||||
|
@@ -308,6 +308,22 @@ class dbal_mssql extends dbal
|
||||
return str_replace("'", "''", $msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Correctly adjust LIKE expression for special characters
|
||||
* MSSQL needs an escape character being defined
|
||||
*/
|
||||
function sql_like_expression($expression)
|
||||
{
|
||||
// Standard for most DBMS
|
||||
if (strpos($expression, '_') === false)
|
||||
{
|
||||
return 'LIKE \'' . $this->sql_escape($expression) . '\'';
|
||||
}
|
||||
|
||||
// sql_like_expression is only allowed directly within single quotes (to ease the use of it), therefore the special writing of ESCAPE below
|
||||
return 'LIKE \'' . $this->sql_escape(str_replace('_', "\_", $expression)) . "' ESCAPE '\\'";
|
||||
}
|
||||
|
||||
/**
|
||||
* return sql error array
|
||||
* @access private
|
||||
|
@@ -319,6 +319,22 @@ class dbal_mssql_odbc extends dbal
|
||||
return str_replace("'", "''", $msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Correctly adjust LIKE expression for special characters
|
||||
* MSSQL needs an escape character being defined
|
||||
*/
|
||||
function sql_like_expression($expression)
|
||||
{
|
||||
// Standard for most DBMS
|
||||
if (strpos($expression, '_') === false)
|
||||
{
|
||||
return 'LIKE \'' . $this->sql_escape($expression) . '\'';
|
||||
}
|
||||
|
||||
// sql_like_expression is only allowed directly within single quotes (to ease the use of it), therefore the special writing of ESCAPE below
|
||||
return 'LIKE \'' . $this->sql_escape(str_replace('_', "\_", $expression)) . "' ESCAPE '\\'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Build db-specific query data
|
||||
* @access private
|
||||
|
@@ -241,6 +241,20 @@ class dbal_sqlite extends dbal
|
||||
return @sqlite_escape_string($msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Correctly adjust LIKE expression for special characters
|
||||
* For SQLite an underscore is a not-known character... this may change with SQLite3
|
||||
*/
|
||||
function sql_like_expression($expression)
|
||||
{
|
||||
if (strpos($expression, '_') === false)
|
||||
{
|
||||
return "LIKE '" . $this->sql_escape($expression) . "'";
|
||||
}
|
||||
|
||||
return "GLOB '" . $this->sql_escape(str_replace('%', '*', $expression)) . "'";
|
||||
}
|
||||
|
||||
/**
|
||||
* return sql error array
|
||||
* @access private
|
||||
|
Reference in New Issue
Block a user