aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/db/dbal.php27
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';
+ }
}
}