mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-15 05:24:41 +01:00
sql_in_set only allows empty sets if the last parameter is set to true, otherwise it will throw an error message and a backtrace
git-svn-id: file:///svn/phpbb/trunk@6913 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
31e546c5e4
commit
fcfe045307
@ -300,22 +300,35 @@ class dbal
|
||||
}
|
||||
|
||||
/**
|
||||
* Build IN, NOT IN, = and <> sql comparison string.
|
||||
* Build IN or NOT IN sql comparison string, uses <> or = on single element
|
||||
* arrays to improve comparison speed
|
||||
* @access public
|
||||
* @param string $field name of the sql column that shall be compared
|
||||
* @param array $array array of values that are allowed (IN) or not allowed (NOT IN)
|
||||
* @param bool $negate true for IN (), false for NOT IN ()
|
||||
* @param bool $allow_empty_set Allow $array to be empty, this function will return 1=1 or 1=0 then
|
||||
*/
|
||||
function sql_in_set($field, $array, $negate = false)
|
||||
function sql_in_set($field, $array, $negate = false, $allow_empty_set = false)
|
||||
{
|
||||
if (!sizeof($array))
|
||||
{
|
||||
// NOT IN () actually means everything so use a tautology
|
||||
if ($negate)
|
||||
if (!$allow_empty_set)
|
||||
{
|
||||
return '1=1';
|
||||
// Print the backtrace to help identifying the location of the problematic code
|
||||
$this->sql_error('No values specified for SQL IN comparison');
|
||||
}
|
||||
// IN () actually means nothing so use a contradiction
|
||||
else
|
||||
{
|
||||
return '1=0';
|
||||
// NOT IN () actually means everything so use a tautology
|
||||
if ($negate)
|
||||
{
|
||||
return '1=1';
|
||||
}
|
||||
// IN () actually means nothing so use a contradiction
|
||||
else
|
||||
{
|
||||
return '1=0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user