diff options
| author | Nils Adermann <naderman@naderman.de> | 2007-01-20 23:35:47 +0000 |
|---|---|---|
| committer | Nils Adermann <naderman@naderman.de> | 2007-01-20 23:35:47 +0000 |
| commit | fcfe045307485a1dd1ff50773815855e42200719 (patch) | |
| tree | 5fc10eb4b95271709adcbf39c7ed24c16686bfe8 /phpBB/includes | |
| parent | 31e546c5e4ecd012ef9d93fa68f42c793e417303 (diff) | |
| download | forums-fcfe045307485a1dd1ff50773815855e42200719.tar forums-fcfe045307485a1dd1ff50773815855e42200719.tar.gz forums-fcfe045307485a1dd1ff50773815855e42200719.tar.bz2 forums-fcfe045307485a1dd1ff50773815855e42200719.tar.xz forums-fcfe045307485a1dd1ff50773815855e42200719.zip | |
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
Diffstat (limited to 'phpBB/includes')
| -rw-r--r-- | phpBB/includes/db/dbal.php | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php index df6e453329..ffe5228665 100644 --- a/phpBB/includes/db/dbal.php +++ b/phpBB/includes/db/dbal.php @@ -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'; + } } } |
