aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/db/dbal.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php
index dcf9947ddf..53850b77b2 100644
--- a/phpBB/includes/db/dbal.php
+++ b/phpBB/includes/db/dbal.php
@@ -285,6 +285,49 @@ class dbal
return $query;
}
+ function sql_in_set($field, $array)
+ {
+ if (!sizeof($array))
+ {
+ trigger_error('No values specified for SQL IN comparison', E_USER_ERROR);
+ }
+
+ $bitfield = (strpos($field, 'bitfield') !== false);
+
+ $values = array();
+ foreach ($array as $var)
+ {
+ if (is_null($var))
+ {
+ $values[] = 'NULL';
+ }
+ else if (is_string($var))
+ {
+ if (!$bitfield)
+ {
+ $values[] = "'" . $this->sql_escape($var) . "'";
+ }
+ else
+ {
+ $values[] = $this->sql_escape_binary($var);
+ }
+ }
+ else
+ {
+ $values[] = (is_bool($var)) ? intval($var) : $var;
+ }
+ }
+
+ if (sizeof($values) == 1)
+ {
+ return $field . ' = ' . $values[0];
+ }
+ else
+ {
+ return $field . ' IN (' . implode(',', $values) . ')';
+ }
+ }
+
function sql_escape_binary($msg)
{
return "'" . $this->sql_escape($msg) . "'";