aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/db
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/db')
-rw-r--r--phpBB/includes/db/dbal.php18
-rw-r--r--phpBB/includes/db/firebird.php5
-rw-r--r--phpBB/includes/db/oracle.php5
3 files changed, 28 insertions, 0 deletions
diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php
index 0e1d6cba33..5418ed394b 100644
--- a/phpBB/includes/db/dbal.php
+++ b/phpBB/includes/db/dbal.php
@@ -412,6 +412,24 @@ class dbal
}
/**
+ * Run binary AND operator on DB column.
+ * Results in sql statement: "{$column_name} & (1 << {$bit}) {$compare}"
+ *
+ * @param string $column_name The column name to use
+ * @param int $bit The value to use for the AND operator, will be converted to (1 << $bit). Is used by options, using the number schema... 0, 1, 2...29
+ * @param string $compare Any custom SQL code after the check (for example "= 0")
+ */
+ function sql_bit_and($column_name, $bit, $compare = '')
+ {
+ if (method_exists($this, '_sql_bit_and'))
+ {
+ return $this->_sql_bit_and($column_name, $bit, $compare);
+ }
+
+ return $column_name . ' & ' . (1 << $bit) . (($compare) ? ' ' . $compare : '');
+ }
+
+ /**
* Run more than one insert statement.
*
* @param string $table table name to run the statements on
diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php
index 3b31942a8b..f5e8595382 100644
--- a/phpBB/includes/db/firebird.php
+++ b/phpBB/includes/db/firebird.php
@@ -446,6 +446,11 @@ class dbal_firebird extends dbal
return $data;
}
+ function _sql_bit_and($column_name, $bit, $compare = '')
+ {
+ return 'BIN_AND(' . $column_name . ', ' . (1 << $bit) . ')' . (($compare) ? ' ' . $compare : '');
+ }
+
/**
* return sql error array
* @access private
diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/oracle.php
index a140c4b676..10f4a1a7a7 100644
--- a/phpBB/includes/db/oracle.php
+++ b/phpBB/includes/db/oracle.php
@@ -568,6 +568,11 @@ class dbal_oracle extends dbal
return $data;
}
+ function _sql_bit_and($column_name, $bit, $compare = '')
+ {
+ return 'BITAND(' . $column_name . ', ' . (1 << $bit) . ')' . (($compare) ? ' ' . $compare : '');
+ }
+
/**
* return sql error array
* @access private