aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/db
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2012-07-18 11:07:32 +0200
committerJoas Schilling <nickvergessen@gmx.de>2012-07-18 11:07:32 +0200
commitf4136eacdc319b2029692a9c19a845a115b94129 (patch)
treef610d14df9e80ee74e8b35e4e8b8183170555f02 /phpBB/includes/db
parent3637cd395e39c1fa5b7279222abe1da5d2abcd00 (diff)
parentb176b86f111a05338ed3c74026bcf19d42ec0ee3 (diff)
downloadforums-f4136eacdc319b2029692a9c19a845a115b94129.tar
forums-f4136eacdc319b2029692a9c19a845a115b94129.tar.gz
forums-f4136eacdc319b2029692a9c19a845a115b94129.tar.bz2
forums-f4136eacdc319b2029692a9c19a845a115b94129.tar.xz
forums-f4136eacdc319b2029692a9c19a845a115b94129.zip
Merge branch 'develop' of git://github.com/phpbb/phpbb3 into feature/new-tz-handling
Diffstat (limited to 'phpBB/includes/db')
-rw-r--r--phpBB/includes/db/dbal.php31
-rw-r--r--phpBB/includes/db/mssql.php8
-rw-r--r--phpBB/includes/db/mssql_odbc.php8
-rw-r--r--phpBB/includes/db/mssqlnative.php10
-rw-r--r--phpBB/includes/db/mysql.php8
-rw-r--r--phpBB/includes/db/mysqli.php8
6 files changed, 72 insertions, 1 deletions
diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php
index cf54d455f7..159703d3be 100644
--- a/phpBB/includes/db/dbal.php
+++ b/phpBB/includes/db/dbal.php
@@ -284,6 +284,37 @@ class dbal
}
/**
+ * Build a case expression
+ *
+ * Note: The two statements action_true and action_false must have the same data type (int, vchar, ...) in the database!
+ *
+ * @param string $condition The condition which must be true, to use action_true rather then action_else
+ * @param string $action_true SQL expression that is used, if the condition is true
+ * @param string $action_else SQL expression that is used, if the condition is false, optional
+ * @return string CASE expression including the condition and statements
+ */
+ public function sql_case($condition, $action_true, $action_false = false)
+ {
+ $sql_case = 'CASE WHEN ' . $condition;
+ $sql_case .= ' THEN ' . $action_true;
+ $sql_case .= ($action_false !== false) ? ' ELSE ' . $action_false : '';
+ $sql_case .= ' END';
+ return $sql_case;
+ }
+
+ /**
+ * Build a concatenated expression
+ *
+ * @param string $expr1 Base SQL expression where we append the second one
+ * @param string $expr2 SQL expression that is appended to the first expression
+ * @return string Concatenated string
+ */
+ public function sql_concatenate($expr1, $expr2)
+ {
+ return $expr1 . ' || ' . $expr2;
+ }
+
+ /**
* Returns whether results of a query need to be buffered to run a transaction while iterating over them.
*
* @return bool Whether buffering is required.
diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php
index abeabc389f..fb044b492f 100644
--- a/phpBB/includes/db/mssql.php
+++ b/phpBB/includes/db/mssql.php
@@ -92,6 +92,14 @@ class dbal_mssql extends dbal
}
/**
+ * {@inheritDoc}
+ */
+ public function sql_concatenate($expr1, $expr2)
+ {
+ return $expr1 . ' + ' . $expr2;
+ }
+
+ /**
* SQL Transaction
* @access private
*/
diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php
index 6e24f4e9e8..64fa9634d1 100644
--- a/phpBB/includes/db/mssql_odbc.php
+++ b/phpBB/includes/db/mssql_odbc.php
@@ -110,6 +110,14 @@ class dbal_mssql_odbc extends dbal
}
/**
+ * {@inheritDoc}
+ */
+ public function sql_concatenate($expr1, $expr2)
+ {
+ return $expr1 . ' + ' . $expr2;
+ }
+
+ /**
* SQL Transaction
* @access private
*/
diff --git a/phpBB/includes/db/mssqlnative.php b/phpBB/includes/db/mssqlnative.php
index 8a4503f111..1f37d54ecb 100644
--- a/phpBB/includes/db/mssqlnative.php
+++ b/phpBB/includes/db/mssqlnative.php
@@ -260,6 +260,14 @@ class dbal_mssqlnative extends dbal
/**
* {@inheritDoc}
*/
+ public function sql_concatenate($expr1, $expr2)
+ {
+ return $expr1 . ' + ' . $expr2;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
function sql_buffer_nested_transactions()
{
return true;
@@ -435,7 +443,7 @@ class dbal_mssqlnative extends dbal
unset($row['line2'], $row['line3']);
}
}
- return $row;
+ return (sizeof($row)) ? $row : false;
}
/**
diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php
index eb38e3e913..8d1f805870 100644
--- a/phpBB/includes/db/mysql.php
+++ b/phpBB/includes/db/mysql.php
@@ -120,6 +120,14 @@ class dbal_mysql extends dbal
}
/**
+ * {@inheritDoc}
+ */
+ public function sql_concatenate($expr1, $expr2)
+ {
+ return 'CONCAT(' . $expr1 . ', ' . $expr2 . ')';
+ }
+
+ /**
* SQL Transaction
* @access private
*/
diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php
index 4210a58002..e07cd35e24 100644
--- a/phpBB/includes/db/mysqli.php
+++ b/phpBB/includes/db/mysqli.php
@@ -123,6 +123,14 @@ class dbal_mysqli extends dbal
}
/**
+ * {@inheritDoc}
+ */
+ public function sql_concatenate($expr1, $expr2)
+ {
+ return 'CONCAT(' . $expr1 . ', ' . $expr2 . ')';
+ }
+
+ /**
* SQL Transaction
* @access private
*/